213 LOG_WRITE("Error: Repository doesn't exit or currupt!"); |
213 LOG_WRITE("Error: Repository doesn't exit or currupt!"); |
214 LOG_LEAVEFN("CUserAgent::ReadUserAgentDataL()"); |
214 LOG_LEAVEFN("CUserAgent::ReadUserAgentDataL()"); |
215 User::Leave(KErrNotReady); |
215 User::Leave(KErrNotReady); |
216 } |
216 } |
217 |
217 |
218 /* ---------------- Read default UA string ---------------- */ |
|
219 LOG_WRITE("Reading default UA string from cenrep."); |
|
220 if(!iBrowserCenrepStr) |
218 if(!iBrowserCenrepStr) |
221 { |
219 { |
222 iBrowserCenrepStr = HBufC::NewL(KMaxUserAgentStringLength); |
220 iBrowserCenrepStr = HBufC::NewL(KMaxUserAgentStringLength); |
223 } |
221 } |
224 |
222 |
225 TPtr tempPtr = iBrowserCenrepStr->Des(); |
223 TPtr tempPtr = iBrowserCenrepStr->Des(); |
226 |
224 retCode = iRepository->Get(KWebUtilsIgnoreConfig, ignoreConfig); |
227 retCode = iRepository->Get(EDefaultUserAgentString, tempPtr); |
225 if(retCode != KErrNone || ignoreConfig == _L("0")) |
228 if(retCode != KErrNone) |
226 {/* ---------------- Read default UA string ---------------- */ |
229 { |
227 LOG_WRITE("Reading default UA string from cenrep."); |
230 LOG_WRITE_FORMAT("Error: Reading default UA string from cenrep failed! (%d)",retCode); |
228 |
231 LOG_LEAVEFN("CUserAgent::ReadUserAgentDataL()"); |
229 retCode = iRepository->Get(EDefaultUserAgentString, tempPtr); |
232 User::Leave(retCode); |
230 if(retCode != KErrNone) |
233 } |
231 { |
234 |
232 LOG_WRITE_FORMAT("Error: Reading default UA string from cenrep failed! (%d)",retCode); |
235 if(!IsUAStringEmpty(tempPtr)) |
233 LOG_LEAVEFN("CUserAgent::ReadUserAgentDataL()"); |
236 { |
234 User::Leave(retCode); |
237 LOG_WRITE("Successfully read default UA string from cenrep, can use this as UA string"); |
235 } |
238 |
236 |
239 iUAStrQueried = TRUE; |
237 if(!IsUAStringEmpty(tempPtr)) |
240 |
238 { |
241 LOG_LEAVEFN("CUserAgent::ReadUserAgentDataL()"); |
239 LOG_WRITE("Successfully read default UA string from cenrep, can use this as UA string"); |
242 return; |
240 |
243 } |
241 iUAStrQueried = TRUE; |
244 |
242 |
|
243 LOG_LEAVEFN("CUserAgent::ReadUserAgentDataL()"); |
|
244 return; |
|
245 } |
|
246 } |
245 ReadAndCreateUAStringL(tempPtr); |
247 ReadAndCreateUAStringL(tempPtr); |
246 LOG_WRITE("Successfully created a new UA string."); |
248 LOG_WRITE("Successfully created a new UA string."); |
247 |
249 |
248 // Mark the flag to indicate successful read |
250 // Mark the flag to indicate successful read |
249 iUAStrQueried = TRUE; |
251 iUAStrQueried = TRUE; |
313 LOG_LEAVEFN("CUserAgent::ReadMMSUserAgentStringL()"); |
318 LOG_LEAVEFN("CUserAgent::ReadMMSUserAgentStringL()"); |
314 return; |
319 return; |
315 } |
320 } |
316 |
321 |
317 /* ---------------- Read all variant fragments and build a UA string ---------------- */ |
322 /* ---------------- Read all variant fragments and build a UA string ---------------- */ |
318 ReadAndCreateUAStringL(tempPtr); |
323 GetMMSFragmentsL(); |
319 |
324 tempPtr.Append(iMMSHardwareType); |
320 LOG_WRITE("Successfully created a new MMS UA string."); |
325 tempPtr.Append(KSpaceChar); |
321 |
326 tempPtr.Append(iMMSS60Version); |
|
327 tempPtr.Append(KSpaceChar); |
|
328 tempPtr.Append(iMMSMIDPVersion); |
|
329 tempPtr.Append(KSpaceChar); |
|
330 tempPtr.Append(iMMSCLDCVersion); |
|
331 |
|
332 if(!IsUAStringEmpty(tempPtr)) |
|
333 { |
|
334 LOG_WRITE("Successfully created a new MMS UA string."); |
|
335 } |
|
336 else |
|
337 { |
|
338 LOG_WRITE("Failed to create a new MMS UA string...Exiting anyway"); |
|
339 } |
|
340 |
322 iMMSUAStrQueried = TRUE; |
341 iMMSUAStrQueried = TRUE; |
323 LOG_LEAVEFN("CUserAgent::ReadMMSUserAgentStringL()"); |
342 LOG_LEAVEFN("CUserAgent::ReadMMSUserAgentStringL()"); |
324 return; |
343 return; |
325 } |
344 } |
326 |
345 |
327 // --------------------------------------------------------- |
346 // --------------------------------------------------------- |
328 // CUserAgent::GetFragmentsL() |
347 // CUserAgent::GetFragmentsL() |
329 // Gets all required fragments from CenRep |
348 // Gets all required fragments from CenRep |
344 // CUserAgent::GetFragmentsL() |
363 // CUserAgent::GetFragmentsL() |
345 // Gets all required fragments from OSExt APIs/CenRep |
364 // Gets all required fragments from OSExt APIs/CenRep |
346 // --------------------------------------------------------- |
365 // --------------------------------------------------------- |
347 void CUserAgent::GetFragmentsL() |
366 void CUserAgent::GetFragmentsL() |
348 { |
367 { |
349 |
|
350 #ifdef BRDO_BROWSER_50_FF |
|
351 TInt osExtFailed(0); |
|
352 TRAP(osExtFailed, GetFragmentsFromOSExtL()); |
|
353 #endif |
|
354 |
|
355 if(iSymbianVersion.Length() <= 0) |
368 if(iSymbianVersion.Length() <= 0) |
356 { |
369 { |
357 LOG_WRITE("Reading SymbianVersion from osext extended api or cenrep."); |
370 LOG_WRITE("Reading SymbianVersion from cenrep."); |
358 User::LeaveIfError(GetCenRepFragment(ESymbianOSVersion, iSymbianVersion)); |
371 GetCenRepFragment(ESymbianOSVersion, iSymbianVersion); |
359 } |
372 } |
360 |
|
361 if(iS60Version.Length() <= 0) |
373 if(iS60Version.Length() <= 0) |
362 { |
374 { |
363 LOG_WRITE("Reading S60Version from osext extended api or cenrep."); |
375 LOG_WRITE("Reading S60Version from cenrep."); |
364 User::LeaveIfError(GetCenRepFragment(ES60Version, iS60Version)); |
376 GetCenRepFragment(ES60Version, iS60Version); |
365 } |
377 } |
366 |
|
367 if(iHardwareType.Length() <= 0) |
378 if(iHardwareType.Length() <= 0) |
368 { |
379 { |
369 LOG_WRITE("Reading HardwareVersion from osext extended api or cenrep."); |
380 LOG_WRITE("Reading HardwareVersion from cenrep."); |
370 User::LeaveIfError(GetCenRepFragment(EHardwareType, iHardwareType)); |
381 GetCenRepFragment(EHardwareType, iHardwareType); |
371 } |
382 if(iHardwareType.Length() > 0) |
372 |
383 { iHardwareType.Append(KPlaceHolderSemiColon); |
|
384 } |
|
385 } |
373 if(iMIDPCLDCVersion.Length() <= 0) |
386 if(iMIDPCLDCVersion.Length() <= 0) |
374 { |
387 { |
375 LOG_WRITE("Reading MIDPCLDCVersion from osext extended api or cenrep."); |
388 LOG_WRITE("Reading MIDPCLDCVersion from cenrep."); |
376 User::LeaveIfError(GetCenRepFragment(EMIDP_CLDCVersion, iMIDPCLDCVersion)); |
389 GetCenRepFragment(EMIDP_CLDCVersion, iMIDPCLDCVersion); |
377 } |
390 } |
|
391 //Only for 5.0 and above as 3.2 does not support OSExt APIs. |
|
392 #ifdef BRDO_BROWSER_50_FF |
|
393 if(iSymbianVersion.Length() <= 0 || iS60Version.Length() <= 0 || iHardwareType.Length() <= 0) |
|
394 { |
|
395 LOG_WRITE("Read from CenRep Failed... trying osext extended api"); |
|
396 GetFragmentsFromOSExtL(); |
|
397 } |
|
398 #endif |
378 } |
399 } |
379 |
400 |
380 // --------------------------------------------------------- |
401 // --------------------------------------------------------- |
381 // CUserAgent::ReadAndCreateUAStringL() |
402 // CUserAgent::ReadAndCreateUAStringL() |
382 // Reads verious fragments from OSExt APIs/CenRep and crates the UA string |
403 // Reads verious fragments from OSExt APIs/CenRep and crates the UA string |
383 // --------------------------------------------------------- |
404 // --------------------------------------------------------- |
384 void CUserAgent::ReadAndCreateUAStringL(TPtr &aUAStringPtr) |
405 void CUserAgent::ReadAndCreateUAStringL(TPtr &aUAStringPtr) |
385 { |
406 { |
386 GetFragmentsL(); |
407 GetFragmentsL(); |
387 |
408 |
388 // |
409 // Mozilla/5.0 (<Symbian Version> <Series60Version> <HardwareType> <MIDP_CLDC Version> ) AppleWebKit/413 (KHTML, like Gecko) BrowserName/Version |
389 // Mozilla/5.0 (<Symbian Version> U; [en]; <Series60Version> <HardwareType> <MIDP_CLDC Version> ) AppleWebKit/413 (KHTML, like Gecko) Safari/413 |
410 |
390 // |
|
391 |
|
392 aUAStringPtr.Copy(KPlaceHolderMozillaVer); |
411 aUAStringPtr.Copy(KPlaceHolderMozillaVer); |
393 aUAStringPtr.Append(KSpaceChar); |
412 aUAStringPtr.Append(KSpaceChar); |
394 |
413 if(iSymbianVersion.Length() > 0 || iS60Version.Length() > 0 || iHardwareType.Length() > 0 || iMIDPCLDCVersion.Length() > 0) |
395 aUAStringPtr.Append(KPlaceHolderOpen); |
414 { |
396 |
415 aUAStringPtr.Append(KPlaceHolderOpen); |
397 aUAStringPtr.Append(iSymbianVersion); |
416 |
|
417 aUAStringPtr.Append(iSymbianVersion); |
|
418 aUAStringPtr.Append(KSpaceChar); |
|
419 |
|
420 aUAStringPtr.Append(iS60Version); |
|
421 aUAStringPtr.Append(KSpaceChar); |
|
422 |
|
423 aUAStringPtr.Append(iHardwareType); |
|
424 aUAStringPtr.Append(KSpaceChar); |
|
425 |
|
426 aUAStringPtr.Append(iMIDPCLDCVersion); |
|
427 aUAStringPtr.Append(KSpaceChar); |
|
428 |
|
429 aUAStringPtr.Append(KPlaceHolderClose); |
|
430 } |
398 aUAStringPtr.Append(KSpaceChar); |
431 aUAStringPtr.Append(KSpaceChar); |
399 |
432 aUAStringPtr.Append(KPlaceHolderComponent); |
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 |
433 |
413 aUAStringPtr.Append(KSpaceChar); |
434 aUAStringPtr.Append(KSpaceChar); |
414 aUAStringPtr.Append(iBrowserNameAndVersionStr->Des()); |
435 aUAStringPtr.Append(iBrowserNameAndVersionStr->Des()); |
415 |
|
416 aUAStringPtr.Append(KSpaceChar); |
|
417 aUAStringPtr.Append(KPlaceHolderComponent); |
|
418 } |
436 } |
419 |
437 |
420 // --------------------------------------------------------- |
438 // --------------------------------------------------------- |
421 // CUserAgent::ReadURLUserAgentProfileL() |
439 // CUserAgent::ReadURLUserAgentProfileL() |
422 // Reads the URL to UA profile from cenrep |
440 // Reads the URL to UA profile from cenrep |
710 // CUserAgent::GetBrowserNameAndVersionL() |
728 // CUserAgent::GetBrowserNameAndVersionL() |
711 // Gets the Browser Version including the Browser name, major version, minor version, SVN rev |
729 // Gets the Browser Version including the Browser name, major version, minor version, SVN rev |
712 // ------------------------------------------------------------------------------- |
730 // ------------------------------------------------------------------------------- |
713 void CUserAgent::GetBrowserNameAndVersionL() |
731 void CUserAgent::GetBrowserNameAndVersionL() |
714 { |
732 { |
|
733 TInt ret(0); |
|
734 TBuf<64> BrowserName(0); |
715 TInt length = KMaxBrowserVersionStringLength + KMaxBrowserNameLength; |
735 TInt length = KMaxBrowserVersionStringLength + KMaxBrowserNameLength; |
716 iBrowserNameAndVersionStr = HBufC::NewL( length); |
736 iBrowserNameAndVersionStr = HBufC::NewL( length); |
717 |
737 |
718 iBrowserNameAndVersionStr->Des().Append(KPlaceHolderBrowserName); |
738 ret = iRepository->Get(KWebUtilsBrowserName, BrowserName); |
|
739 if(ret != KErrNone) |
|
740 { |
|
741 LOG_WRITE("Error: Reading default Browser Name from cenrep failed!"); |
|
742 iBrowserNameAndVersionStr->Des().Append(KPlaceHolderBrowserName); |
|
743 } |
|
744 else |
|
745 { |
|
746 iBrowserNameAndVersionStr->Des().Append(BrowserName); |
|
747 } |
719 iBrowserNameAndVersionStr->Des().Append(KPlaceHolderSlash); |
748 iBrowserNameAndVersionStr->Des().Append(KPlaceHolderSlash); |
720 iBrowserNameAndVersionStr->Des().Append( *iBrowserVersionStr ); |
749 iBrowserNameAndVersionStr->Des().Append( *iBrowserVersionStr ); |
721 } |
750 } |
|
751 |
|
752 // --------------------------------------------------------- |
|
753 // CUserAgent::GetFragmentsL() |
|
754 // Gets all required fragments from OSExt APIs/CenRep |
|
755 // --------------------------------------------------------- |
|
756 void CUserAgent::GetMMSFragmentsL() |
|
757 { |
|
758 if(iMMSHardwareType.Length() <= 0) |
|
759 { |
|
760 LOG_WRITE("Reading HardwareVersion from cenrep."); |
|
761 iRepository->Get(KWebUtilsMMSUsrAg2, iMMSHardwareType); |
|
762 if(iMMSHardwareType.Length() > 0) |
|
763 { iMMSHardwareType.Append(KPlaceHolderSemiColon); |
|
764 } |
|
765 } |
|
766 if(iMMSS60Version.Length() <= 0) |
|
767 { |
|
768 LOG_WRITE("Reading S60Version from cenrep."); |
|
769 iRepository->Get(KWebUtilsMMSUsrAg3, iMMSS60Version); |
|
770 } |
|
771 if(iMMSMIDPVersion.Length() <= 0) |
|
772 { |
|
773 LOG_WRITE("Reading MIDPCLDCVersion from cenrep."); |
|
774 iRepository->Get(KWebUtilsMMSUsrAg4, iMMSMIDPVersion); |
|
775 } |
|
776 if(iMMSCLDCVersion.Length() <= 0) |
|
777 { |
|
778 LOG_WRITE("Reading MIDPCLDCVersion from cenrep."); |
|
779 iRepository->Get(KWebUtilsMMSUsrAg5, iMMSCLDCVersion); |
|
780 } |
|
781 //Only for 5.0 and above as 3.2 does not support OSExt APIs. |
|
782 #ifdef BRDO_BROWSER_50_FF |
|
783 if(iMMSS60Version.Length() <= 0 || iMMSHardwareType.Length() <= 0) |
|
784 { |
|
785 LOG_WRITE("Read from CenRep Failed... trying osext extended api"); |
|
786 GetFragmentsFromOSExtL(); |
|
787 iMMSHardwareType = iHardwareType; |
|
788 iMMSS60Version = iS60Version; |
|
789 } |
|
790 #endif |
|
791 } |
722 // End of file |
792 // End of file |