|
1 /* |
|
2 * Copyright (c) 2005 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 the License "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: Implementation of class CUserAgent. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 #include <e32std.h> |
|
21 #include <f32file.h> |
|
22 #include <eikenv.h> |
|
23 |
|
24 #include <Browser_platform_variant.hrh> |
|
25 #include "webUtilsCommon.h" |
|
26 #include "CUserAgent.h" |
|
27 #include "WebUtilsLogger.h" |
|
28 |
|
29 #include "WebUtilsInternalCRKeys.h" |
|
30 |
|
31 |
|
32 #define KPlaceHolderMozillaVer _L("Mozilla/5.0") |
|
33 #define KPlaceHolderSecurity _L("U;") |
|
34 #define KPlaceHolderComponent _L("AppleWebKit/525 (KHTML, like Gecko) Version/3.0 Safari/525") |
|
35 #define KPlaceHolderBrowserNG _L("BrowserNG") |
|
36 |
|
37 #define KPlaceHolderSlash _L("/") |
|
38 #define KPlaceHolderSymbianOS _L("SymbianOS") |
|
39 #define KPlaceHolderSeries60 _L("Series60") |
|
40 |
|
41 #define KPlaceHolderOpen _L("(") |
|
42 #define KPlaceHolderClose _L(")") |
|
43 #define KPlaceHolderSemiColon _L(";") |
|
44 #define KPlaceHolderPeriod _L(".") |
|
45 |
|
46 const TInt KMaxUserAgentStringLength = 256; |
|
47 const TInt KMaxBrowserVersionStringLength = 20; |
|
48 const TInt KMaxBrowserNameLength = 20; |
|
49 |
|
50 // Space character. |
|
51 LOCAL_D const TUint8 KSpaceChar = ' '; |
|
52 |
|
53 // ================= MEMBER FUNCTIONS ======================= |
|
54 |
|
55 // --------------------------------------------------------- |
|
56 // CUserAgent::CUserAgent() |
|
57 // Constructor with parent |
|
58 // --------------------------------------------------------- |
|
59 // |
|
60 CUserAgent::CUserAgent() |
|
61 { |
|
62 LOG_CREATE |
|
63 LOG_WRITE( "CUserAgent::CUserAgent" ); |
|
64 } |
|
65 |
|
66 // --------------------------------------------------------- |
|
67 // CUserAgent::~CUserAgent() |
|
68 // Destructor |
|
69 // --------------------------------------------------------- |
|
70 // |
|
71 CUserAgent::~CUserAgent() |
|
72 { |
|
73 LOG_WRITE( "CUserAgent::~CUserAgent" ); |
|
74 |
|
75 delete iRepository; |
|
76 |
|
77 delete iBrowserCenrepStr; |
|
78 delete iMMSCenrepStr; |
|
79 |
|
80 delete iUAProfURL; |
|
81 delete iUAProfURL3G; |
|
82 delete iBrowserVersionStr; |
|
83 delete iBrowserNameAndVersionStr; |
|
84 |
|
85 LOG_DELETE |
|
86 } |
|
87 |
|
88 // --------------------------------------------------------- |
|
89 // CUserAgent* CUserAgent::NewL() |
|
90 // --------------------------------------------------------- |
|
91 // |
|
92 EXPORT_C CUserAgent* CUserAgent::NewL() |
|
93 { |
|
94 CUserAgent* self = new (ELeave) CUserAgent; |
|
95 CleanupStack::PushL(self); |
|
96 self->ConstructL(); |
|
97 CleanupStack::Pop(); |
|
98 return self; |
|
99 } |
|
100 |
|
101 // --------------------------------------------------------- |
|
102 // CUserAgent::ConstructL() |
|
103 // Symbian constructor |
|
104 // --------------------------------------------------------- |
|
105 // |
|
106 void CUserAgent::ConstructL() |
|
107 { |
|
108 LOG_ENTERFN("CUserAgent::ConstructL()"); |
|
109 |
|
110 iBrowserCenrepStr = iMMSCenrepStr = NULL; |
|
111 iUAProfURL = iUAProfURL3G = NULL; |
|
112 iRepository = NULL; |
|
113 |
|
114 iRepository = CRepository::NewL(KCRUidWebUtils); |
|
115 iUAStrQueried = iMMSUAStrQueried = iURLUAProfQueried = FALSE; |
|
116 GetBrowserVersionL(); |
|
117 GetBrowserNameAndVersionL(); |
|
118 |
|
119 LOG_LEAVEFN("CUserAgent::ConstructL()"); |
|
120 } |
|
121 |
|
122 // --------------------------------------------------------- |
|
123 // CUserAgent::UserAgentL() |
|
124 // Returns complete constructed user agent string. |
|
125 // --------------------------------------------------------- |
|
126 // |
|
127 EXPORT_C HBufC8* CUserAgent::UserAgentL() |
|
128 { |
|
129 LOG_ENTERFN("CUserAgent::UserAgent()"); |
|
130 TRAPD( ErrorCode,ReadUserAgentStringL()); |
|
131 if(ErrorCode != KErrNone) |
|
132 { |
|
133 LOG_WRITE_FORMAT("ERROR: ReadUserAgentStringL failed! (%d) Returning NULL",ErrorCode); |
|
134 LOG_LEAVEFN("CUserAgent::UserAgent()"); |
|
135 return NULL; |
|
136 } |
|
137 |
|
138 HBufC8 *UAStringBuf = HBufC8::NewL(KMaxUserAgentStringLength); |
|
139 TPtr8 UAStringPtr = UAStringBuf->Des(); |
|
140 UAStringPtr.Copy(iBrowserCenrepStr->Des()); |
|
141 |
|
142 LOG_LEAVEFN("CUserAgent::UserAgent()"); |
|
143 return UAStringBuf; |
|
144 } |
|
145 |
|
146 // --------------------------------------------------------- |
|
147 // CUserAgent::MMSUserAgentL() |
|
148 // Returns complete constructed MMS user agent string. |
|
149 // --------------------------------------------------------- |
|
150 EXPORT_C HBufC8* CUserAgent::MMSUserAgentL() |
|
151 { |
|
152 LOG_ENTERFN("CUserAgent::MMSUserAgent()"); |
|
153 |
|
154 TRAPD( ErrorCode,ReadMMSUserAgentStringL()); |
|
155 if(ErrorCode != KErrNone) |
|
156 { |
|
157 LOG_WRITE_FORMAT("ERROR: ReadMMSUserAgentStringL failed! (%d) Returning NULL",ErrorCode); |
|
158 LOG_LEAVEFN("CUserAgent::MMSUserAgent()"); |
|
159 return NULL; |
|
160 } |
|
161 |
|
162 HBufC8 *MMSUAStringBuf = HBufC8::NewL(KMaxUserAgentStringLength); |
|
163 TPtr8 UAStringPtr = MMSUAStringBuf->Des(); |
|
164 UAStringPtr.Copy(iMMSCenrepStr->Des()); |
|
165 |
|
166 LOG_LEAVEFN("CUserAgent::MMSUserAgent()"); |
|
167 return MMSUAStringBuf; |
|
168 } |
|
169 |
|
170 // --------------------------------------------------------- |
|
171 // CUserAgent::URLToUserAgentProfileL() |
|
172 // Fetches URL to UA profile. |
|
173 // --------------------------------------------------------- |
|
174 EXPORT_C TInt CUserAgent::URLToUserAgentProfileL(TDes8 &aUAProfURL, TDes8 &aUAProfURL3G) |
|
175 { |
|
176 LOG_ENTERFN("CUserAgent::URLToUserAgentProfileL()"); |
|
177 |
|
178 TRAPD( ErrorCode,ReadURLUserAgentProfileL()); |
|
179 if(ErrorCode != KErrNone) |
|
180 { |
|
181 LOG_WRITE_FORMAT("ERROR: ReadURLUserAgentProfileL failed! (%d) Returning NULL",ErrorCode); |
|
182 LOG_LEAVEFN("CUserAgent::URLToUserAgentProfileL()"); |
|
183 return ErrorCode; |
|
184 } |
|
185 |
|
186 aUAProfURL.Copy(iUAProfURL->Des()); |
|
187 aUAProfURL3G.Copy(iUAProfURL3G->Des()); |
|
188 |
|
189 LOG_LEAVEFN("CUserAgent::URLToUserAgentProfileL()"); |
|
190 |
|
191 return ErrorCode; |
|
192 } |
|
193 |
|
194 // --------------------------------------------------------- |
|
195 // CUserAgent::ReadUserAgentStringL() |
|
196 // Reads the UA string from cenrep |
|
197 // --------------------------------------------------------- |
|
198 void CUserAgent::ReadUserAgentStringL() |
|
199 { |
|
200 LOG_ENTERFN("CUserAgent::ReadUserAgentStringL()"); |
|
201 TInt retCode (KErrNotReady); |
|
202 |
|
203 // If the string queried already, dont read again |
|
204 if(iUAStrQueried) |
|
205 { |
|
206 LOG_WRITE("UA String already in cache. No read will be performed."); |
|
207 LOG_LEAVEFN("CUserAgent::ReadUserAgentDataL()"); |
|
208 return; |
|
209 } |
|
210 |
|
211 if(!iRepository) |
|
212 { |
|
213 LOG_WRITE("Error: Repository doesn't exit or currupt!"); |
|
214 LOG_LEAVEFN("CUserAgent::ReadUserAgentDataL()"); |
|
215 User::Leave(KErrNotReady); |
|
216 } |
|
217 |
|
218 /* ---------------- Read default UA string ---------------- */ |
|
219 LOG_WRITE("Reading default UA string from cenrep."); |
|
220 if(!iBrowserCenrepStr) |
|
221 { |
|
222 iBrowserCenrepStr = HBufC::NewL(KMaxUserAgentStringLength); |
|
223 } |
|
224 |
|
225 TPtr tempPtr = iBrowserCenrepStr->Des(); |
|
226 |
|
227 retCode = iRepository->Get(EDefaultUserAgentString, tempPtr); |
|
228 if(retCode != KErrNone) |
|
229 { |
|
230 LOG_WRITE_FORMAT("Error: Reading default UA string from cenrep failed! (%d)",retCode); |
|
231 LOG_LEAVEFN("CUserAgent::ReadUserAgentDataL()"); |
|
232 User::Leave(retCode); |
|
233 } |
|
234 |
|
235 if(!IsUAStringEmpty(tempPtr)) |
|
236 { |
|
237 LOG_WRITE("Successfully read default UA string from cenrep, can use this as UA string"); |
|
238 |
|
239 iUAStrQueried = TRUE; |
|
240 |
|
241 LOG_LEAVEFN("CUserAgent::ReadUserAgentDataL()"); |
|
242 return; |
|
243 } |
|
244 |
|
245 ReadAndCreateUAStringL(tempPtr); |
|
246 LOG_WRITE("Successfully created a new UA string."); |
|
247 |
|
248 // Mark the flag to indicate successful read |
|
249 iUAStrQueried = TRUE; |
|
250 |
|
251 LOG_LEAVEFN("CUserAgent::ReadUserAgentDataL()"); |
|
252 return; |
|
253 } |
|
254 |
|
255 // --------------------------------------------------------- |
|
256 // CUserAgent::IsUAStringEmpty() |
|
257 // Checks if the UA string is empty or "NONE" |
|
258 // --------------------------------------------------------- |
|
259 bool CUserAgent::IsUAStringEmpty(const TPtr &aUAString) |
|
260 { |
|
261 return (aUAString.Compare(_L("NONE")) == 0 || aUAString.Length() == 0); |
|
262 } |
|
263 |
|
264 |
|
265 // --------------------------------------------------------- |
|
266 // CUserAgent::ReadMMSUserAgentStringL() |
|
267 // Reads the MMS UA string from cenrep |
|
268 // --------------------------------------------------------- |
|
269 |
|
270 void CUserAgent::ReadMMSUserAgentStringL() |
|
271 { |
|
272 LOG_ENTERFN("CUserAgent::ReadMMSUserAgentStringL()"); |
|
273 TInt retCode (KErrNotReady); |
|
274 |
|
275 // If the string queried already, dont read again |
|
276 if(iMMSUAStrQueried) |
|
277 { |
|
278 LOG_WRITE("MMS UA String already in cache. No read will be performed."); |
|
279 LOG_LEAVEFN("CUserAgent::ReadMMSUserAgentStringL()"); |
|
280 return; |
|
281 } |
|
282 |
|
283 if(!iRepository) |
|
284 { |
|
285 LOG_WRITE("Error: Repository doesn't exit or currupt!"); |
|
286 LOG_LEAVEFN("CUserAgent::ReadMMSUserAgentStringL()"); |
|
287 |
|
288 User::Leave(KErrNotReady);// -1; // Error code ? |
|
289 } |
|
290 |
|
291 /* ---------------- Read MMS default UA string ---------------- */ |
|
292 if(!iMMSCenrepStr) |
|
293 { |
|
294 iMMSCenrepStr = HBufC::NewL(KMaxUserAgentStringLength); |
|
295 } |
|
296 |
|
297 LOG_WRITE("Default MMS UA string is to be read from cenrep"); |
|
298 TPtr tempPtr = iMMSCenrepStr->Des(); |
|
299 |
|
300 retCode = iRepository->Get(EDefaultMMSUserAgentString, tempPtr); |
|
301 if(retCode != KErrNone) |
|
302 { |
|
303 LOG_WRITE("Error: Reading default MMS UA string from cenrep failed!"); |
|
304 LOG_LEAVEFN("CUserAgent::ReadMMSUserAgentStringL()"); |
|
305 User::Leave(retCode); |
|
306 } |
|
307 |
|
308 if(!IsUAStringEmpty(tempPtr)) |
|
309 { |
|
310 LOG_WRITE("Successfully read default MMS UA string from cenrep, can use this as MMS UA string"); |
|
311 |
|
312 iMMSUAStrQueried = TRUE; |
|
313 LOG_LEAVEFN("CUserAgent::ReadMMSUserAgentStringL()"); |
|
314 return; |
|
315 } |
|
316 |
|
317 /* ---------------- Read all variant fragments and build a UA string ---------------- */ |
|
318 ReadAndCreateUAStringL(tempPtr); |
|
319 |
|
320 LOG_WRITE("Successfully created a new MMS UA string."); |
|
321 |
|
322 iMMSUAStrQueried = TRUE; |
|
323 LOG_LEAVEFN("CUserAgent::ReadMMSUserAgentStringL()"); |
|
324 return; |
|
325 } |
|
326 |
|
327 // --------------------------------------------------------- |
|
328 // CUserAgent::GetFragmentsL() |
|
329 // Gets all required fragments from CenRep |
|
330 // --------------------------------------------------------- |
|
331 TInt CUserAgent::GetCenRepFragment(TUserAgentStringKeys aFragmentType, TDes& fragmentValue) |
|
332 { |
|
333 TInt retCode(iRepository->Get(aFragmentType, fragmentValue)); |
|
334 |
|
335 if(fragmentValue.Length() <= 0) |
|
336 { |
|
337 retCode = KErrNotReady; |
|
338 } |
|
339 |
|
340 return retCode; |
|
341 } |
|
342 |
|
343 // --------------------------------------------------------- |
|
344 // CUserAgent::GetFragmentsL() |
|
345 // Gets all required fragments from OSExt APIs/CenRep |
|
346 // --------------------------------------------------------- |
|
347 void CUserAgent::GetFragmentsL() |
|
348 { |
|
349 |
|
350 #ifdef BRDO_BROWSER_50_FF |
|
351 TInt osExtFailed(0); |
|
352 TRAP(osExtFailed, GetFragmentsFromOSExtL()); |
|
353 #endif |
|
354 |
|
355 if(iSymbianVersion.Length() <= 0) |
|
356 { |
|
357 LOG_WRITE("Reading SymbianVersion from osext extended api or cenrep."); |
|
358 User::LeaveIfError(GetCenRepFragment(ESymbianOSVersion, iSymbianVersion)); |
|
359 } |
|
360 |
|
361 if(iS60Version.Length() <= 0) |
|
362 { |
|
363 LOG_WRITE("Reading S60Version from osext extended api or cenrep."); |
|
364 User::LeaveIfError(GetCenRepFragment(ES60Version, iS60Version)); |
|
365 } |
|
366 |
|
367 if(iHardwareType.Length() <= 0) |
|
368 { |
|
369 LOG_WRITE("Reading HardwareVersion from osext extended api or cenrep."); |
|
370 User::LeaveIfError(GetCenRepFragment(EHardwareType, iHardwareType)); |
|
371 } |
|
372 |
|
373 if(iMIDPCLDCVersion.Length() <= 0) |
|
374 { |
|
375 LOG_WRITE("Reading MIDPCLDCVersion from osext extended api or cenrep."); |
|
376 User::LeaveIfError(GetCenRepFragment(EMIDP_CLDCVersion, iMIDPCLDCVersion)); |
|
377 } |
|
378 } |
|
379 |
|
380 // --------------------------------------------------------- |
|
381 // CUserAgent::ReadAndCreateUAStringL() |
|
382 // Reads verious fragments from OSExt APIs/CenRep and crates the UA string |
|
383 // --------------------------------------------------------- |
|
384 void CUserAgent::ReadAndCreateUAStringL(TPtr &aUAStringPtr) |
|
385 { |
|
386 GetFragmentsL(); |
|
387 |
|
388 // |
|
389 // Mozilla/5.0 (<Symbian Version> U; [en]; <Series60Version> <HardwareType> <MIDP_CLDC Version> ) AppleWebKit/413 (KHTML, like Gecko) Safari/413 |
|
390 // |
|
391 |
|
392 aUAStringPtr.Copy(KPlaceHolderMozillaVer); |
|
393 aUAStringPtr.Append(KSpaceChar); |
|
394 |
|
395 aUAStringPtr.Append(KPlaceHolderOpen); |
|
396 |
|
397 aUAStringPtr.Append(iSymbianVersion); |
|
398 aUAStringPtr.Append(KSpaceChar); |
|
399 |
|
400 aUAStringPtr.Append(KPlaceHolderSecurity); |
|
401 aUAStringPtr.Append(KSpaceChar); |
|
402 |
|
403 aUAStringPtr.Append(iS60Version); |
|
404 aUAStringPtr.Append(KSpaceChar); |
|
405 |
|
406 aUAStringPtr.Append(iHardwareType); |
|
407 |
|
408 aUAStringPtr.Append(KSpaceChar); |
|
409 aUAStringPtr.Append(iMIDPCLDCVersion); |
|
410 aUAStringPtr.Append(KSpaceChar); |
|
411 aUAStringPtr.Append(KPlaceHolderClose); |
|
412 |
|
413 aUAStringPtr.Append(KSpaceChar); |
|
414 aUAStringPtr.Append(KPlaceHolderBrowserNG); |
|
415 aUAStringPtr.Append(KSpaceChar); |
|
416 aUAStringPtr.Append(iBrowserVersionStr->Des()); |
|
417 |
|
418 aUAStringPtr.Append(KSpaceChar); |
|
419 aUAStringPtr.Append(KPlaceHolderComponent); |
|
420 } |
|
421 |
|
422 // --------------------------------------------------------- |
|
423 // CUserAgent::ReadURLUserAgentProfileL() |
|
424 // Reads the URL to UA profile from cenrep |
|
425 // --------------------------------------------------------- |
|
426 |
|
427 void CUserAgent::ReadURLUserAgentProfileL() |
|
428 { |
|
429 LOG_ENTERFN("CUserAgent::ReadURLUserAgentProfileL()"); |
|
430 |
|
431 // If the string queried already, dont read again |
|
432 if(iURLUAProfQueried) |
|
433 { |
|
434 LOG_WRITE("URL to UA profile already in cache. No read will be performed."); |
|
435 LOG_LEAVEFN("CUserAgent::ReadURLUserAgentProfileL()"); |
|
436 return; |
|
437 } |
|
438 |
|
439 if(!iRepository) |
|
440 { |
|
441 LOG_WRITE("Error: Repository doesn't exit or currupt!"); |
|
442 LOG_LEAVEFN("CUserAgent::ReadURLUserAgentProfileL() - repository not instantiated"); |
|
443 User::Leave(KErrNotReady); |
|
444 } |
|
445 |
|
446 /* ---------------- Read URL to 2G UA profile ---------------- */ |
|
447 if(!iUAProfURL) |
|
448 { |
|
449 iUAProfURL = HBufC::NewL(KMaxUserAgentStringLength); |
|
450 } |
|
451 |
|
452 TPtr TempPtr2G = iUAProfURL->Des(); |
|
453 TInt RetCode = iRepository->Get(EURLUAProfile, TempPtr2G); |
|
454 if(RetCode != KErrNone) |
|
455 { |
|
456 LOG_WRITE("Error: Reading URL to 2G UA profile from cenrep failed!"); |
|
457 LOG_LEAVEFN("CUserAgent::ReadURLUserAgentProfileL()"); |
|
458 User::Leave(RetCode); |
|
459 } |
|
460 |
|
461 |
|
462 /* ---------------- Read URL to 3G UA profile ---------------- */ |
|
463 if(!iUAProfURL3G) |
|
464 { |
|
465 iUAProfURL3G = HBufC::NewL(KMaxUserAgentStringLength); |
|
466 } |
|
467 |
|
468 TPtr TempPtr3G = iUAProfURL3G->Des(); |
|
469 RetCode = iRepository->Get(EURL3GUAProfile, TempPtr3G); |
|
470 if(RetCode != KErrNone) |
|
471 { |
|
472 delete iUAProfURL; |
|
473 iUAProfURL = NULL; |
|
474 |
|
475 LOG_WRITE("Error: Reading URL to 3G UA profile from cenrep failed!"); |
|
476 LOG_LEAVEFN("CUserAgent::ReadURLUserAgentProfileL()"); |
|
477 User::Leave(RetCode); |
|
478 } |
|
479 |
|
480 iURLUAProfQueried = TRUE; |
|
481 LOG_LEAVEFN("CUserAgent::ReadURLUserAgentProfileL()"); |
|
482 User::Leave(KErrNone); |
|
483 } |
|
484 |
|
485 |
|
486 #ifdef BRDO_BROWSER_50_FF |
|
487 |
|
488 // --------------------------------------------------------- |
|
489 // CUserAgent::GetFragmentsL() |
|
490 // Gets all required fragments from OSExt |
|
491 // --------------------------------------------------------- |
|
492 void CUserAgent::GetFragmentsFromOSExtL() |
|
493 { |
|
494 RFs fs; |
|
495 CleanupClosePushL< RFs >( fs ); |
|
496 User::LeaveIfError( fs.Connect() ); |
|
497 |
|
498 if(iSymbianVersion.Length() <= 0) |
|
499 { |
|
500 GetOSExtFragment(ESymbianOSVersion, iSymbianVersion, fs); |
|
501 } |
|
502 |
|
503 if(iS60Version.Length() <= 0) |
|
504 { |
|
505 GetOSExtFragment(ES60Version, iS60Version, fs); |
|
506 } |
|
507 |
|
508 if(iHardwareType.Length() <= 0) |
|
509 { |
|
510 GetOSExtFragment(EHardwareType, iHardwareType, fs); |
|
511 } |
|
512 CleanupStack::PopAndDestroy(); // fs |
|
513 } |
|
514 |
|
515 |
|
516 // --------------------------------------------------------- |
|
517 // CUserAgent::GetOSExtFragment() |
|
518 // Gets various fragments from OS Ext APIs |
|
519 // --------------------------------------------------------- |
|
520 TInt CUserAgent::GetOSExtFragment(TUserAgentStringKeys aFragmentType, TDes& fragmentValue, RFs& fs) |
|
521 { |
|
522 TInt retCode(0); |
|
523 |
|
524 switch(aFragmentType) |
|
525 { |
|
526 case ESymbianOSVersion: |
|
527 retCode = GetOSVersion( fragmentValue,fs ); |
|
528 break; |
|
529 |
|
530 case ES60Version: |
|
531 retCode = GetS60Version( fragmentValue,fs ); |
|
532 break; |
|
533 |
|
534 case EHardwareType: |
|
535 retCode = GetHardwareVersion( fragmentValue,fs ); |
|
536 break; |
|
537 |
|
538 default: |
|
539 retCode = KErrNotFound; |
|
540 break; |
|
541 } |
|
542 if(fragmentValue.Length() <= 0) |
|
543 { |
|
544 retCode = KErrNotReady; |
|
545 } |
|
546 |
|
547 return retCode; |
|
548 } |
|
549 |
|
550 // --------------------------------------------------------- |
|
551 // CUserAgent::GetOSVersion() |
|
552 // Gets the Symbian OS Version |
|
553 // --------------------------------------------------------- |
|
554 TInt CUserAgent::GetOSVersion(TDes& osVersion,RFs& aFs ) |
|
555 { |
|
556 LOG_ENTERFN("CUserAgent::GetOSVersion"); |
|
557 |
|
558 SysVersionInfo::TSymbianOSVersion os; |
|
559 |
|
560 TInt retCode (SysVersionInfo::GetVersionInfo( os, aFs )); |
|
561 if(retCode != KErrNone) |
|
562 { |
|
563 LOG_LEAVEFN("CUserAgent::GetOSVersion"); |
|
564 return retCode; |
|
565 } |
|
566 |
|
567 osVersion.Append(KPlaceHolderSymbianOS); |
|
568 osVersion.Append(KPlaceHolderSlash); |
|
569 osVersion.AppendNum(os.iMajorVersion); |
|
570 osVersion.Append('.'); |
|
571 osVersion.AppendNum(os.iMinorVersion); |
|
572 osVersion.Append(';'); |
|
573 |
|
574 LOG_LEAVEFN("CUserAgent::GetOSVersion"); |
|
575 return retCode; |
|
576 } |
|
577 |
|
578 // --------------------------------------------------------- |
|
579 // CUserAgent::GetS60Version() |
|
580 // Gets the S60 Version |
|
581 // --------------------------------------------------------- |
|
582 TInt CUserAgent::GetS60Version(TDes& s60Version, RFs& aFs) |
|
583 { |
|
584 VersionInfo::TPlatformVersion pVersion; |
|
585 |
|
586 TInt retCode (VersionInfo::GetVersion(pVersion,aFs)); |
|
587 if(retCode != KErrNone) |
|
588 { |
|
589 return retCode; |
|
590 } |
|
591 s60Version.Append(KPlaceHolderSeries60); |
|
592 s60Version.Append(KPlaceHolderSlash); |
|
593 s60Version.AppendNum(pVersion.iMajorVersion); |
|
594 s60Version.Append('.'); |
|
595 s60Version.AppendNum(pVersion.iMinorVersion); |
|
596 return retCode; |
|
597 } |
|
598 |
|
599 |
|
600 // ----------------------------------------------------------------------------- |
|
601 // CUserAgent::GetHardwareVersion() |
|
602 // Gets the Hardware Version including Manufacture, Model names with revision |
|
603 // ------------------------------------------------------------------------------- |
|
604 |
|
605 TInt CUserAgent::GetHardwareVersion( TDes& aHardwareType, RFs& aFs ) |
|
606 { |
|
607 SysVersionInfo::TProductVersion pVersion; |
|
608 |
|
609 TInt retCode(SysVersionInfo::GetVersionInfo( pVersion,aFs )); |
|
610 if(retCode != KErrNone) |
|
611 { |
|
612 return retCode; |
|
613 } |
|
614 aHardwareType.Append(pVersion.iManufacturer); |
|
615 aHardwareType.Append(pVersion.iModel); |
|
616 aHardwareType.Append(KPlaceHolderSlash); |
|
617 aHardwareType.Append(pVersion.iProduct); |
|
618 aHardwareType.Append(pVersion.iRevision); |
|
619 aHardwareType.Append(KPlaceHolderSemiColon); |
|
620 |
|
621 return retCode; |
|
622 } |
|
623 |
|
624 // ------------------------------------------------------------------------ |
|
625 // CUserAgent::GetVersion() |
|
626 // This method gets the requested version information as string. |
|
627 // @param aType A version information type specified by TVersionInfoType. |
|
628 // @param aValue Stores version information. |
|
629 // @return System wide error code. |
|
630 // This api is implemented for future use, not used currently |
|
631 // ------------------------------------------------------------------------- |
|
632 TInt CUserAgent::GetVersion(const SysVersionInfo::TVersionInfoType aType, TDes& aValue) |
|
633 { |
|
634 aValue.Zero(); |
|
635 |
|
636 /* To get the firmware version that is composed of the version info of multiple images (core + variants images), |
|
637 To get the customer software version. This identifies the user friendly version of e.g. operator/country/regional variant image. |
|
638 or To get the model version depending on aType EFWVersion/EOPVersion/EModelVersion.*/ |
|
639 |
|
640 TInt ret( SysVersionInfo::GetVersionInfo( aType , aValue) ); |
|
641 //ret will return KErrNotSupported if osext extended api failed. |
|
642 |
|
643 return ret; |
|
644 } |
|
645 |
|
646 #endif //#ifdef BRDO_BROWSER_50_FF |
|
647 |
|
648 // ----------------------------------------------------------------------------- |
|
649 // CUserAgent::BrowserNameAndVersionL() |
|
650 // Returns the Browser version |
|
651 // ------------------------------------------------------------------------------- |
|
652 |
|
653 EXPORT_C HBufC* CUserAgent::BrowserVersionL() |
|
654 { |
|
655 return iBrowserVersionStr; |
|
656 } |
|
657 |
|
658 // ----------------------------------------------------------------------------- |
|
659 // CUserAgent::BrowserNameAndVersionL() |
|
660 // Returns the Browser name and version |
|
661 // ------------------------------------------------------------------------------- |
|
662 |
|
663 EXPORT_C HBufC* CUserAgent::BrowserNameAndVersionL() |
|
664 { |
|
665 return iBrowserNameAndVersionStr; |
|
666 } |
|
667 |
|
668 |
|
669 // ----------------------------------------------------------------------------- |
|
670 // CUserAgent::GetBrowserVersionL() |
|
671 // Gets the Browser Version including major version, minor version and SVN rev |
|
672 // ------------------------------------------------------------------------------- |
|
673 void CUserAgent::GetBrowserVersionL() |
|
674 { |
|
675 |
|
676 TInt ret(0); |
|
677 TBuf<64> BrowserVersionMajor(0); |
|
678 TBuf<64> BrowserVersionMinor(0); |
|
679 TBuf<64> BrowserVersionSVNRev(0); |
|
680 |
|
681 iBrowserVersionStr = HBufC::NewL(KMaxBrowserVersionStringLength); |
|
682 |
|
683 TPtr BrowserVersionPtr = iBrowserVersionStr->Des(); |
|
684 |
|
685 |
|
686 ret = iRepository->Get(KWebUtilsBrowserVersionMajor, BrowserVersionMajor); |
|
687 if(ret == KErrNone) |
|
688 { |
|
689 ret = iRepository->Get(KWebUtilsBrowserVersionMinor, BrowserVersionMinor); |
|
690 if(ret == KErrNone) |
|
691 { |
|
692 ret = iRepository->Get(KWebUtilsBrowserVersionSVNRev, BrowserVersionSVNRev); |
|
693 if(ret == KErrNone) |
|
694 { |
|
695 BrowserVersionPtr.Append(BrowserVersionMajor); |
|
696 BrowserVersionPtr.Append(KPlaceHolderPeriod); |
|
697 BrowserVersionPtr.Append(BrowserVersionMinor); |
|
698 BrowserVersionPtr.Append(KPlaceHolderPeriod); |
|
699 BrowserVersionPtr.Append(BrowserVersionSVNRev); ; |
|
700 } |
|
701 } |
|
702 } |
|
703 |
|
704 if(ret != KErrNone) |
|
705 { |
|
706 LOG_WRITE("Error: Reading default Browser Version from cenrep failed!"); |
|
707 LOG_LEAVEFN("CUserAgent::BrowserVersion()"); |
|
708 } |
|
709 } |
|
710 |
|
711 // ----------------------------------------------------------------------------- |
|
712 // CUserAgent::GetBrowserNameAndVersionL() |
|
713 // Gets the Browser Version including the Browser name, major version, minor version, SVN rev |
|
714 // ------------------------------------------------------------------------------- |
|
715 void CUserAgent::GetBrowserNameAndVersionL() |
|
716 { |
|
717 TInt length = KMaxBrowserVersionStringLength + KMaxBrowserNameLength; |
|
718 iBrowserNameAndVersionStr = HBufC::NewL( length); |
|
719 |
|
720 iBrowserNameAndVersionStr->Des().Append(KPlaceHolderBrowserNG); |
|
721 iBrowserNameAndVersionStr->Des().Append(KSpaceChar); // add a gap |
|
722 iBrowserNameAndVersionStr->Des().Append( *iBrowserVersionStr ); |
|
723 } |
|
724 // End of file |