|
1 /* |
|
2 * Copyright (c) 2010 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: |
|
15 * |
|
16 */ |
|
17 |
|
18 #include "javauseragent.h" |
|
19 #ifdef RD_JAVA_S60_RELEASE_10_1_ONWARDS |
|
20 #include <QWebpage.h> |
|
21 #include "javaenvinfo.h" |
|
22 #else |
|
23 #include <cuseragent.h> |
|
24 #endif |
|
25 |
|
26 #ifdef RD_JAVA_S60_RELEASE_10_1_ONWARDS |
|
27 class Page: public QWebPage |
|
28 { |
|
29 public: |
|
30 QString userAgentForUrl ( const QUrl & url ) const; |
|
31 |
|
32 }; |
|
33 |
|
34 QString Page::userAgentForUrl ( const QUrl & url ) const |
|
35 { |
|
36 return url.toString(); |
|
37 } |
|
38 #endif |
|
39 |
|
40 HBufC* JavaUserAgent::GetUserAgentL() |
|
41 { |
|
42 #ifdef RD_JAVA_S60_RELEASE_10_1_ONWARDS |
|
43 /*QApplication app(); |
|
44 QUrl uri; |
|
45 Page page; |
|
46 QString webUserAgent = page.userAgentForUrl(uri); |
|
47 HBufC* agent = HBufC::NewMaxLC(webUserAgent.length()); |
|
48 agent->Des().Copy(webUserAgent.utf16()); |
|
49 agent->Des().Append(*(Java::JavaEnvInfo::GetUserAgentHeaderL())); |
|
50 return agent; |
|
51 */ |
|
52 _LIT(KString,"null"); |
|
53 HBufC* agent = HBufC::NewLC(5); |
|
54 *agent = KString; |
|
55 CleanupStack::Pop(agent); |
|
56 return agent; |
|
57 |
|
58 #else |
|
59 |
|
60 CUserAgent* userAgent = CUserAgent::NewL(); |
|
61 CleanupStack::PushL(userAgent); |
|
62 |
|
63 HBufC8* agent8 = userAgent->UserAgentL(); |
|
64 CleanupStack::PushL(agent8); |
|
65 |
|
66 HBufC* agent = HBufC::NewMaxLC(agent8->Length()); |
|
67 agent->Des().Copy(*agent8); |
|
68 |
|
69 CleanupStack::Pop(agent); |
|
70 CleanupStack::PopAndDestroy(agent8); |
|
71 CleanupStack::PopAndDestroy(userAgent); |
|
72 return agent; |
|
73 #endif |
|
74 } |