|
1 /* |
|
2 * Copyright (c) 2002 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: |
|
15 * Implementation of Scheme handler interface implementation for http:// scheme |
|
16 * |
|
17 * |
|
18 */ |
|
19 |
|
20 |
|
21 // INCLUDE FILES |
|
22 |
|
23 #include "HttpHandler.h" |
|
24 #include "SchemeDispLogger.h" |
|
25 #include <ECom.h> // For REComSession |
|
26 #include <eikenv.h> |
|
27 #include <DocumentHandler.h> |
|
28 #include <apgcli.h> |
|
29 #include <apparc.h> |
|
30 #include <eikdoc.h> |
|
31 #include <eikproc.h> |
|
32 #include <f32file.h> |
|
33 #include <APGTASK.H> |
|
34 #include <w32std.h> |
|
35 #include <BrowserOverriddenSettings.h> |
|
36 |
|
37 _LIT( KBrowserPrefix, "4 " ); |
|
38 LOCAL_C const TUid KUidBrowser = { 0x10008D39 }; |
|
39 |
|
40 // ================= CONSTANTS ======================= |
|
41 |
|
42 // ================= MEMBER FUNCTIONS ======================= |
|
43 |
|
44 // --------------------------------------------------------- |
|
45 // CHttpHandler::NewL() |
|
46 // --------------------------------------------------------- |
|
47 // |
|
48 CHttpHandler* CHttpHandler::NewL( const TDesC& aUrl ) |
|
49 { |
|
50 CLOG_ENTERFN( "CHttpHandler::NewL()" ); |
|
51 |
|
52 CHttpHandler* self=new(ELeave) CHttpHandler(); |
|
53 CleanupStack::PushL(self); |
|
54 self->ConstructL( aUrl ); |
|
55 CleanupStack::Pop(self); |
|
56 |
|
57 CLOG_LEAVEFN( "CHttpHandler::NewL()" ); |
|
58 |
|
59 return self; |
|
60 } |
|
61 |
|
62 // --------------------------------------------------------- |
|
63 // CHttpHandler::~CHttpHandler() |
|
64 // --------------------------------------------------------- |
|
65 // |
|
66 CHttpHandler::~CHttpHandler() |
|
67 { |
|
68 CLOG_ENTERFN( "CHttpHandler::~CHttpHandler()" ); |
|
69 |
|
70 if(iDoc != NULL) |
|
71 { |
|
72 CEikProcess* hostProcess = CEikonEnv::Static()->Process(); |
|
73 hostProcess->DestroyDocument(iDoc); |
|
74 iDoc = NULL; |
|
75 } |
|
76 |
|
77 delete iLauncher; |
|
78 |
|
79 CLOG_LEAVEFN( "CHttpHandler::~CHttpHandler()" ); |
|
80 } |
|
81 |
|
82 // --------------------------------------------------------- |
|
83 // CHttpHandler::CHttpHandler() |
|
84 // --------------------------------------------------------- |
|
85 // |
|
86 CHttpHandler::CHttpHandler() : CBaseHandler() |
|
87 { |
|
88 // Deliberately do nothing here : See ConstructL() for initialisation |
|
89 // completion. |
|
90 } |
|
91 |
|
92 // --------------------------------------------------------- |
|
93 // CHttpHandler::ConstructL() |
|
94 // --------------------------------------------------------- |
|
95 // |
|
96 void CHttpHandler::ConstructL( const TDesC& aUrl ) |
|
97 { |
|
98 iParsedUrl = HBufC::NewL( aUrl.Length() ); |
|
99 iParsedUrl->Des().Copy( aUrl ); |
|
100 } |
|
101 |
|
102 // --------------------------------------------------------- |
|
103 // CHttpHandler::HandleUrlEmbeddedL() |
|
104 // --------------------------------------------------------- |
|
105 // |
|
106 void CHttpHandler::HandleUrlEmbeddedL() |
|
107 { |
|
108 CLOG_ENTERFN( "CHttpHandler::HandleUrlEmbeddedL()" ); |
|
109 /* Launch the appropriate application in embedded mode */ |
|
110 HBufC* buf16 = HBufC::NewLC( |
|
111 iParsedUrl->Des().Length() + KBrowserPrefix.iTypeLength ); |
|
112 buf16->Des().Copy( KBrowserPrefix ); |
|
113 buf16->Des().Append( *iParsedUrl ); |
|
114 |
|
115 iLauncher = CBrowserLauncher::NewL(); |
|
116 TBrowserOverriddenSettings settings; |
|
117 settings.SetBrowserSetting( EBrowserOverSettingsFullScreen, 1 ); |
|
118 settings.SetBrowserSetting( EBrowserOverSettingsAutoLoadImages, 1 ); |
|
119 settings.SetBrowserSetting( EBrowserOverSettingsFontSize, EBrowserOverFontSizeLevelNormal ); |
|
120 iLauncher->LaunchBrowserEmbeddedL( buf16->Des(), |
|
121 NULL, |
|
122 this, |
|
123 &settings ); |
|
124 CleanupStack::PopAndDestroy(); // buf16 |
|
125 CLOG_LEAVEFN( "CHttpHandler::HandleUrlEmbeddedL()" ); |
|
126 } |
|
127 |
|
128 // --------------------------------------------------------- |
|
129 // CHttpHandler::HandleUrlStandaloneL() |
|
130 // --------------------------------------------------------- |
|
131 // |
|
132 void CHttpHandler::HandleUrlStandaloneL() |
|
133 { |
|
134 CLOG_ENTERFN( "CHttpHandler::HandleUrlStandaloneL()" ); |
|
135 |
|
136 HBufC* buf16 = HBufC::NewLC( |
|
137 iParsedUrl->Des().Length() + KBrowserPrefix.iTypeLength ); |
|
138 buf16->Des().Copy( KBrowserPrefix ); |
|
139 buf16->Des().Append( *iParsedUrl ); |
|
140 |
|
141 RWsSession wsSession; |
|
142 User::LeaveIfError( wsSession.Connect() ); |
|
143 CleanupClosePushL<RWsSession>( wsSession ); |
|
144 TApaTaskList taskList( wsSession ); |
|
145 TApaTask task = taskList.FindApp( KUidBrowser ); |
|
146 if ( task.Exists() ) |
|
147 { |
|
148 HBufC8* param8 = HBufC8::NewLC( buf16->Length() ); |
|
149 param8->Des().Append( buf16->Des() ); |
|
150 task.SendMessage( TUid::Uid( 0 ), *param8 ); // Uid is not used |
|
151 CleanupStack::PopAndDestroy( param8 ); |
|
152 } |
|
153 else |
|
154 { |
|
155 RApaLsSession appArcSession; |
|
156 User::LeaveIfError( appArcSession.Connect() ); |
|
157 CleanupClosePushL<RApaLsSession>( appArcSession ); |
|
158 TThreadId id; |
|
159 appArcSession.StartDocument( *buf16, KUidBrowser , id ); |
|
160 CleanupStack::PopAndDestroy(); // appArcSession |
|
161 } |
|
162 |
|
163 CleanupStack::PopAndDestroy( 2 ); // buf16, wsSession |
|
164 |
|
165 CLOG_LEAVEFN( "CHttpHandler::HandleUrlStandaloneL()" ); |
|
166 } |
|
167 |
|
168 // --------------------------------------------------------- |
|
169 // CHttpHandler::HandleServerAppExit() |
|
170 // --------------------------------------------------------- |
|
171 // |
|
172 void CHttpHandler::HandleServerAppExit(TInt aReason) |
|
173 { |
|
174 CLOG_ENTERFN( "CHttpHandler::HandleServerAppExit" ); |
|
175 |
|
176 if( NULL != iSchemeDoc ) |
|
177 { |
|
178 iSchemeDoc->HandleServerAppExit( aReason ); |
|
179 } |
|
180 |
|
181 CLOG_LEAVEFN( "CHttpHandler::HandleServerAppExit" ); |
|
182 } |
|
183 |