author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Tue, 06 Jul 2010 14:10:26 +0300 | |
changeset 48 | e0d6e9bd3ca7 |
child 50 | 023eef975703 |
permissions | -rw-r--r-- |
48
e0d6e9bd3ca7
Revision: v2.2.3
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
1 |
/* |
e0d6e9bd3ca7
Revision: v2.2.3
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
2 |
* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). |
e0d6e9bd3ca7
Revision: v2.2.3
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
3 |
* All rights reserved. |
e0d6e9bd3ca7
Revision: v2.2.3
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
4 |
* This component and the accompanying materials are made available |
e0d6e9bd3ca7
Revision: v2.2.3
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
5 |
* under the terms of "Eclipse Public License v1.0" |
e0d6e9bd3ca7
Revision: v2.2.3
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
6 |
* which accompanies this distribution, and is available |
e0d6e9bd3ca7
Revision: v2.2.3
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html". |
e0d6e9bd3ca7
Revision: v2.2.3
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
8 |
* |
e0d6e9bd3ca7
Revision: v2.2.3
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
9 |
* Initial Contributors: |
e0d6e9bd3ca7
Revision: v2.2.3
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
10 |
* Nokia Corporation - initial contribution. |
e0d6e9bd3ca7
Revision: v2.2.3
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
11 |
* |
e0d6e9bd3ca7
Revision: v2.2.3
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
12 |
* Contributors: |
e0d6e9bd3ca7
Revision: v2.2.3
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
13 |
* |
e0d6e9bd3ca7
Revision: v2.2.3
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
14 |
* Description: |
e0d6e9bd3ca7
Revision: v2.2.3
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
15 |
* |
e0d6e9bd3ca7
Revision: v2.2.3
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
16 |
*/ |
e0d6e9bd3ca7
Revision: v2.2.3
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
17 |
|
e0d6e9bd3ca7
Revision: v2.2.3
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
18 |
#include "javauseragent.h" |
e0d6e9bd3ca7
Revision: v2.2.3
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
19 |
#ifdef RD_JAVA_S60_RELEASE_10_1_ONWARDS |
e0d6e9bd3ca7
Revision: v2.2.3
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
20 |
#include <QWebpage.h> |
e0d6e9bd3ca7
Revision: v2.2.3
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
21 |
#include "javaenvinfo.h" |
e0d6e9bd3ca7
Revision: v2.2.3
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
22 |
#else |
e0d6e9bd3ca7
Revision: v2.2.3
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
23 |
#include <cuseragent.h> |
e0d6e9bd3ca7
Revision: v2.2.3
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
24 |
#endif |
e0d6e9bd3ca7
Revision: v2.2.3
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
25 |
|
e0d6e9bd3ca7
Revision: v2.2.3
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
26 |
#ifdef RD_JAVA_S60_RELEASE_10_1_ONWARDS |
e0d6e9bd3ca7
Revision: v2.2.3
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
27 |
class Page: public QWebPage |
e0d6e9bd3ca7
Revision: v2.2.3
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
28 |
{ |
e0d6e9bd3ca7
Revision: v2.2.3
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
29 |
public: |
e0d6e9bd3ca7
Revision: v2.2.3
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
30 |
QString userAgentForUrl ( const QUrl & url ) const; |
e0d6e9bd3ca7
Revision: v2.2.3
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
31 |
|
e0d6e9bd3ca7
Revision: v2.2.3
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
32 |
}; |
e0d6e9bd3ca7
Revision: v2.2.3
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
33 |
|
e0d6e9bd3ca7
Revision: v2.2.3
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
34 |
QString Page::userAgentForUrl ( const QUrl & url ) const |
e0d6e9bd3ca7
Revision: v2.2.3
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
35 |
{ |
e0d6e9bd3ca7
Revision: v2.2.3
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
36 |
return url.toString(); |
e0d6e9bd3ca7
Revision: v2.2.3
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
37 |
} |
e0d6e9bd3ca7
Revision: v2.2.3
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
38 |
#endif |
e0d6e9bd3ca7
Revision: v2.2.3
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
39 |
|
e0d6e9bd3ca7
Revision: v2.2.3
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
40 |
HBufC* JavaUserAgent::GetUserAgentL() |
e0d6e9bd3ca7
Revision: v2.2.3
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
41 |
{ |
e0d6e9bd3ca7
Revision: v2.2.3
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
42 |
#ifdef RD_JAVA_S60_RELEASE_10_1_ONWARDS |
e0d6e9bd3ca7
Revision: v2.2.3
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
43 |
/*QApplication app(); |
e0d6e9bd3ca7
Revision: v2.2.3
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
44 |
QUrl uri; |
e0d6e9bd3ca7
Revision: v2.2.3
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
45 |
Page page; |
e0d6e9bd3ca7
Revision: v2.2.3
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
46 |
QString webUserAgent = page.userAgentForUrl(uri); |
e0d6e9bd3ca7
Revision: v2.2.3
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
47 |
HBufC* agent = HBufC::NewMaxLC(webUserAgent.length()); |
e0d6e9bd3ca7
Revision: v2.2.3
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
48 |
agent->Des().Copy(webUserAgent.utf16()); |
e0d6e9bd3ca7
Revision: v2.2.3
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
49 |
agent->Des().Append(*(Java::JavaEnvInfo::GetUserAgentHeaderL())); |
e0d6e9bd3ca7
Revision: v2.2.3
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
50 |
return agent; |
e0d6e9bd3ca7
Revision: v2.2.3
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
51 |
*/ |
e0d6e9bd3ca7
Revision: v2.2.3
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
52 |
_LIT(KString,"null"); |
e0d6e9bd3ca7
Revision: v2.2.3
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
53 |
HBufC* agent = HBufC::NewLC(5); |
e0d6e9bd3ca7
Revision: v2.2.3
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
54 |
*agent = KString; |
e0d6e9bd3ca7
Revision: v2.2.3
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
55 |
CleanupStack::Pop(agent); |
e0d6e9bd3ca7
Revision: v2.2.3
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
56 |
return agent; |
e0d6e9bd3ca7
Revision: v2.2.3
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
57 |
|
e0d6e9bd3ca7
Revision: v2.2.3
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
58 |
#else |
e0d6e9bd3ca7
Revision: v2.2.3
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
59 |
|
e0d6e9bd3ca7
Revision: v2.2.3
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
60 |
CUserAgent* userAgent = CUserAgent::NewL(); |
e0d6e9bd3ca7
Revision: v2.2.3
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
61 |
CleanupStack::PushL(userAgent); |
e0d6e9bd3ca7
Revision: v2.2.3
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
62 |
|
e0d6e9bd3ca7
Revision: v2.2.3
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
63 |
HBufC8* agent8 = userAgent->UserAgentL(); |
e0d6e9bd3ca7
Revision: v2.2.3
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
64 |
CleanupStack::PushL(agent8); |
e0d6e9bd3ca7
Revision: v2.2.3
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
65 |
|
e0d6e9bd3ca7
Revision: v2.2.3
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
66 |
HBufC* agent = HBufC::NewMaxLC(agent8->Length()); |
e0d6e9bd3ca7
Revision: v2.2.3
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
67 |
agent->Des().Copy(*agent8); |
e0d6e9bd3ca7
Revision: v2.2.3
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
68 |
|
e0d6e9bd3ca7
Revision: v2.2.3
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
69 |
CleanupStack::Pop(agent); |
e0d6e9bd3ca7
Revision: v2.2.3
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
70 |
CleanupStack::PopAndDestroy(agent8); |
e0d6e9bd3ca7
Revision: v2.2.3
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
71 |
CleanupStack::PopAndDestroy(userAgent); |
e0d6e9bd3ca7
Revision: v2.2.3
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
72 |
return agent; |
e0d6e9bd3ca7
Revision: v2.2.3
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
73 |
#endif |
e0d6e9bd3ca7
Revision: v2.2.3
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
74 |
} |