|
1 /* |
|
2 * Copyright (c) 2005-2006 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: A helper class for reading Series 60 and Symbian OS versions |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 #ifndef VERSION_STRINGS_H |
|
21 #define VERSION_STRINGS_H |
|
22 |
|
23 // INCLUDES |
|
24 #include <e32base.h> |
|
25 #include <sysutil.h> |
|
26 |
|
27 #include "OnlineSupportLogger.h" |
|
28 |
|
29 // CONSTANTS |
|
30 const TInt KMaxVersionBufLength(10); |
|
31 |
|
32 // MACROS |
|
33 // None |
|
34 |
|
35 // DATA TYPES |
|
36 typedef TBuf8<KMaxVersionBufLength> TVersionBuf; |
|
37 |
|
38 // FUNCTION PROTOTYPES |
|
39 // None |
|
40 |
|
41 // FORWARD DECLARATIONS |
|
42 // None |
|
43 |
|
44 // CLASS DECLARATION |
|
45 |
|
46 /** |
|
47 * CMiniBrowser class |
|
48 * |
|
49 * @since 3.1? |
|
50 */ |
|
51 class TVersionStrings |
|
52 { |
|
53 public: |
|
54 /*! |
|
55 Get the beging index and length of a token in the descriptor. |
|
56 @param aDescriptor |
|
57 @param aSeparator Token separator, for example 0xA for a line feed. |
|
58 @param aToken The token number, zero is the index of the first token. |
|
59 @param aMaxLength The maximum length of the token. If the token length is bigger |
|
60 than aMaxLength the function leaves with KErrTooBig. Give KErrNotFound |
|
61 to not to check the maximum length. |
|
62 @param aBegin On return contains the begin index of the token. |
|
63 The value is unspecified if the function leaves. |
|
64 @param aLength On return contains the length of the token. |
|
65 The value is unspecified if the function leaves. |
|
66 */ |
|
67 static void TokenLocationL( |
|
68 const TDesC& aDescriptor, const TChar aSeparator, const TInt aToken, |
|
69 const TInt aMaxLength, TInt& aBegin, TInt& aLength ) |
|
70 { |
|
71 LOGSTRING( "TokenLocationL" ); |
|
72 |
|
73 TInt locate = aDescriptor.Locate( aSeparator ); |
|
74 if( locate == KErrNotFound ) |
|
75 { |
|
76 User::Leave( KErrNotFound ); |
|
77 } |
|
78 |
|
79 if( aToken ) |
|
80 { |
|
81 // not the last row |
|
82 TokenLocationL( aDescriptor.Right( aDescriptor.Length() - locate - 1 ), |
|
83 aSeparator, aToken - 1, aMaxLength, aBegin, aLength ); |
|
84 aBegin = aBegin + locate + 1; |
|
85 } |
|
86 else |
|
87 { |
|
88 if( aMaxLength != KErrNotFound && locate > aMaxLength ) |
|
89 { |
|
90 User::Leave( KErrTooBig ); |
|
91 } |
|
92 // the last row |
|
93 aBegin = 0; |
|
94 aLength = locate; |
|
95 } |
|
96 LOGSTRING( "TokenLocationL - done" ); |
|
97 }; |
|
98 |
|
99 /*! |
|
100 Gives Series 60 version and SymbianOS version based on product model. |
|
101 Leaves with KErrCorrupt if the version strings could not be read. |
|
102 @aS60Version On return contains Series 60 version, for example 2.6 |
|
103 @aSymbianVersion On return contains Symbian OS version, for example 8.1 |
|
104 */ |
|
105 static void GetUserAgentVersionsL( TVersionBuf& aS60Version, TVersionBuf& aSymbianVersion ) |
|
106 { |
|
107 LOGSTRING( "GetUserAgentVersionsL" ); |
|
108 |
|
109 TBuf<KSysUtilVersionTextLength> versions; |
|
110 TInt err = SysUtil::GetSWVersion( versions ); |
|
111 if( err != KErrNone ) |
|
112 { |
|
113 User::Leave( KErrCorrupt ); |
|
114 } |
|
115 LOGSTRING( "SW:" ); |
|
116 LOGTEXT( versions ); |
|
117 |
|
118 |
|
119 const TChar lineFeedChar( 0xA ); |
|
120 TInt begin(0); |
|
121 TInt len(0); |
|
122 // Since the Series 60 3.0 the Series 60 version is assumed to be in the SW version string |
|
123 TRAP( err, TVersionStrings::TokenLocationL( versions, lineFeedChar, 2, |
|
124 aS60Version.MaxLength(), begin, len ) ); |
|
125 if( err != KErrNone ) |
|
126 { |
|
127 User::Leave( KErrCorrupt ); |
|
128 } |
|
129 aS60Version.Copy( versions.Mid( begin, len ) ); |
|
130 |
|
131 GetSymbianOsVersionL( aS60Version, aSymbianVersion ); |
|
132 LOGSTRING( "S60:" ); |
|
133 LOGTEXT( aS60Version ); |
|
134 LOGSTRING( "Symbian OS:" ); |
|
135 LOGTEXT( aSymbianVersion ); |
|
136 LOGSTRING( "GetUserAgentVersionsL - done" ); |
|
137 } |
|
138 |
|
139 /*! |
|
140 Gives Series 60 version and SymbianOS version based on product model. |
|
141 @aProduct Product, for example RM-1. |
|
142 @aS60Version Series 60 version, for example 2.6 |
|
143 @aSymbianVersion On return contains Symbian OS version, for example 8.1 |
|
144 */ |
|
145 static void GetSymbianOsVersionL( const TDesC8& aS60Version, TVersionBuf& aSymbianVersion ) |
|
146 { |
|
147 _LIT8( KSeries6020, "2.0"); |
|
148 _LIT8( KSeries6021, "2.1"); |
|
149 _LIT8( KSeries6026, "2.6"); |
|
150 _LIT8( KSeries6026m, "2.6m"); |
|
151 _LIT8( KSeries6028, "2.8"); |
|
152 _LIT8( KSeries6030, "S60-30"); |
|
153 _LIT8( KSeries6031, "S60-31"); |
|
154 _LIT8( KSeries6040, "S60-40"); |
|
155 |
|
156 _LIT8( KSymbianOS70s, "7.0s"); |
|
157 _LIT8( KSymbianOS80a, "8.0a"); |
|
158 _LIT8( KSymbianOS81a, "8.1a"); |
|
159 _LIT8( KSymbianOS91, "9.1"); |
|
160 _LIT8( KSymbianOS92, "9.2"); |
|
161 _LIT8( KSymbianOS9x, "9.x"); |
|
162 |
|
163 if( aS60Version.Compare( KSeries6040 ) == 0 ) |
|
164 { |
|
165 aSymbianVersion.Copy( KSymbianOS9x ); |
|
166 } |
|
167 else if( aS60Version.Compare( KSeries6031 ) == 0 ) |
|
168 { |
|
169 aSymbianVersion.Copy( KSymbianOS92 ); |
|
170 } |
|
171 else if( aS60Version.Compare( KSeries6030 ) == 0 ) |
|
172 { |
|
173 aSymbianVersion.Copy( KSymbianOS91 ); |
|
174 } |
|
175 else if( aS60Version.Compare( KSeries6028 ) == 0 ) |
|
176 { |
|
177 aSymbianVersion.Copy( KSymbianOS81a ); |
|
178 } |
|
179 else if( aS60Version.Compare( KSeries6026 ) == 0 || aS60Version.Compare( KSeries6026m ) == 0 ) |
|
180 { |
|
181 aSymbianVersion.Copy( KSymbianOS80a ); |
|
182 } |
|
183 else if( aS60Version.Compare( KSeries6021 ) == 0 || aS60Version.Compare( KSeries6020 ) == 0 ) |
|
184 { |
|
185 aSymbianVersion.Copy( KSymbianOS70s ); |
|
186 } |
|
187 else |
|
188 { |
|
189 User::Leave( KErrNotFound ); |
|
190 } |
|
191 }; |
|
192 |
|
193 }; |
|
194 |
|
195 #endif // VERSION_STRINGS_H |
|
196 |
|
197 // End of File |