|
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 BrowserLauncherService |
|
16 * |
|
17 * |
|
18 */ |
|
19 |
|
20 |
|
21 // INCLUDES |
|
22 #include "BrowserLauncherService.h" |
|
23 #include "BrowserOverriddenSettings.h" |
|
24 #include "LauncherServerCommands.hrh" |
|
25 #include "BrowserAppDocument.h" |
|
26 #include "BrowserAppUi.h" |
|
27 #include "BrowserAsyncExit.h" |
|
28 #include "logger.h" |
|
29 #include <AiwGenericParam.h> |
|
30 #include <s32mem.h> |
|
31 #include "BrowserSpecialLoadObserver.h" |
|
32 #include "MConnection.h" |
|
33 |
|
34 // ----------------------------------------------------------------------------- |
|
35 // CBrowserLauncherService::~CBrowserLauncherService() |
|
36 // ----------------------------------------------------------------------------- |
|
37 // |
|
38 CBrowserLauncherService::~CBrowserLauncherService() |
|
39 { |
|
40 LOG_ENTERFN( "CBrowserLauncherService::~CBrowserLauncherService" ); |
|
41 // The base class has no destructor, thus resources must be freed up here! |
|
42 delete iClientBuffer; iClientBuffer = 0; |
|
43 // Cancel outstanding asynchronous request |
|
44 if ( iMyAsyncMessage.Handle() !=0 ) |
|
45 { |
|
46 iMyAsyncMessage.Complete( KErrCancel ); |
|
47 } |
|
48 } |
|
49 |
|
50 // ----------------------------------------------------------------------------- |
|
51 // CBrowserLauncherService::ProcessMessageSyncL() |
|
52 // ----------------------------------------------------------------------------- |
|
53 // |
|
54 TInt CBrowserLauncherService::ProcessMessageSyncL( TUid /*aEmbeddingApplicationUid*/, |
|
55 TBrowserOverriddenSettings /*aSettings*/, |
|
56 TInt /*aFolderUid*/, |
|
57 TPtrC /*aSeamlessParam*/, |
|
58 TBool /*aIsContentHandlerRegistered*/ ) |
|
59 { |
|
60 LOG_ENTERFN( "CBrowserLauncherService::ProcessMessageSyncL" ); |
|
61 |
|
62 // Do stuff here... |
|
63 return KErrNone; |
|
64 } |
|
65 |
|
66 // ----------------------------------------------------------------------------- |
|
67 // CBrowserLauncherService::ProcessMessageASyncL() |
|
68 // ----------------------------------------------------------------------------- |
|
69 // |
|
70 void CBrowserLauncherService::ProcessMessageASyncL( TUid aEmbeddingApplicationUid, |
|
71 TBrowserOverriddenSettings aSettings, |
|
72 TInt aFolderUid, |
|
73 TPtrC aSeamlessParam, |
|
74 TBool aIsContentHandlerRegistered, |
|
75 TBool aIsOverridenSettings ) |
|
76 { |
|
77 LOG_ENTERFN( "CBrowserLauncherService::ProcessMessageASyncL" ); |
|
78 |
|
79 TBrowserOverriddenSettings* paSettings; |
|
80 TInt seamlessParamLength = aSeamlessParam.Length(); |
|
81 HBufC8* param8 = HBufC8::NewLC( seamlessParamLength ); |
|
82 |
|
83 // Set Browser`s document settings |
|
84 if ( aIsOverridenSettings ) |
|
85 { |
|
86 paSettings = &aSettings; |
|
87 iBrowserDocument->SetOverriddenSettings( paSettings ); |
|
88 } |
|
89 else |
|
90 { |
|
91 iBrowserDocument->SetOverriddenSettings( NULL ); |
|
92 } |
|
93 |
|
94 // Set browser document |
|
95 iBrowserDocument->SetFolderToOpen( aFolderUid ); |
|
96 iBrowserDocument->SetIsContentHandlerRegistered( aIsContentHandlerRegistered ); |
|
97 |
|
98 // Initialize browser |
|
99 iBrowserAppUi->SetEmbeddingAppliacationUid( aEmbeddingApplicationUid ); |
|
100 iBrowserAppUi->InitBrowserL( ); |
|
101 |
|
102 // Load the specified URL |
|
103 param8->Des().Copy( aSeamlessParam ); |
|
104 |
|
105 // If no command or URL was given open the browser with the specified bookmark |
|
106 if ( seamlessParamLength ) |
|
107 { |
|
108 iBrowserAppUi->ParseAndProcessParametersL( *param8 ); |
|
109 iBrowserAppUi->SetViewToBeActivatedIfNeededL( iBrowserAppUi->LastActiveViewId() ); |
|
110 } |
|
111 else |
|
112 { |
|
113 iBrowserAppUi->ParseAndProcessParametersL( *param8, EFalse ); |
|
114 |
|
115 // startup content view to initialize fep/vkb |
|
116 iBrowserAppUi->SetLastActiveViewId( KUidBrowserContentViewId ); |
|
117 iBrowserAppUi->SetViewToBeActivatedIfNeededL( iBrowserAppUi->LastActiveViewId() ); |
|
118 iBrowserAppUi->ActivateLocalViewL( iBrowserAppUi->LastActiveViewId() ); |
|
119 |
|
120 // Now activate bookmarks view |
|
121 iBrowserAppUi->SetLastActiveViewId( KUidBrowserBookmarksViewId ); |
|
122 iBrowserAppUi->SetViewToBeActivatedIfNeededL( iBrowserAppUi->LastActiveViewId() ); |
|
123 } |
|
124 iBrowserAppUi->ActivateLocalViewL( iBrowserAppUi->LastActiveViewId() ); |
|
125 iBrowserAppUi->HandleForegroundEventL( ETrue ); |
|
126 |
|
127 // perform special action for overridden context |
|
128 // could later use as flag for LSK,RSK. |
|
129 switch(aSettings.GetBrowserSetting(EBrowserOverSettingsContextId)) |
|
130 { |
|
131 case EBrowserContextIdFeeds: |
|
132 iBrowserAppUi->SetOverriddenLaunchContextId(EBrowserContextIdFeeds); |
|
133 iBrowserAppUi->LaunchIntoFeedsL(); |
|
134 break; |
|
135 default: |
|
136 // do nothing |
|
137 break; |
|
138 |
|
139 } |
|
140 |
|
141 CleanupStack::PopAndDestroy(); // param8 |
|
142 } |
|
143 |
|
144 // ----------------------------------------------------------------------------- |
|
145 // CBrowserLauncherService::ProcessMessageSyncBufferL() |
|
146 // ----------------------------------------------------------------------------- |
|
147 // |
|
148 TInt CBrowserLauncherService::ProcessMessageSyncBufferL( ) |
|
149 { |
|
150 LOG_ENTERFN( "CBrowserLauncherService::ProcessMessageSyncBufferL" ); |
|
151 |
|
152 // Write iClientBuffer to client`s address space. |
|
153 iMySyncMessage.WriteL( 0,iClientBuffer->Des() ); |
|
154 return KErrNone; |
|
155 } |
|
156 |
|
157 // ----------------------------------------------------------------------------- |
|
158 // CBrowserLauncherService::ProcessBoolsL() |
|
159 // ----------------------------------------------------------------------------- |
|
160 // |
|
161 void CBrowserLauncherService::ProcessBoolsL |
|
162 ( TBool aClientWantsToContinue, TBool aWasContentHandled ) |
|
163 { |
|
164 LOG_ENTERFN( "CBrowserLauncherService::ProcessBoolsL" ); |
|
165 |
|
166 iBrowserAppUi->SetContentHandlingResult( aClientWantsToContinue, aWasContentHandled ); |
|
167 } |
|
168 |
|
169 // ----------------------------------------------------------------------------- |
|
170 // CBrowserLauncherService::DoBrowserExit() |
|
171 // ----------------------------------------------------------------------------- |
|
172 // |
|
173 void CBrowserLauncherService::DoBrowserExit( ) |
|
174 { |
|
175 LOG_ENTERFN( "CBrowserLauncherService::DoBrowserExitL" ); |
|
176 |
|
177 if ( iBrowserAppUi ) |
|
178 { |
|
179 if ( !iBrowserAppUi->ExitInProgress() ) |
|
180 { |
|
181 if (iBrowserAppUi->SpecialLoadObserver().IsConnectionStarted()) // If Connection request is in processing |
|
182 { |
|
183 iBrowserAppUi->Connection().Disconnect(); |
|
184 } |
|
185 else |
|
186 { |
|
187 iBrowserAppUi->iBrowserAsyncExit->Start(); |
|
188 } |
|
189 } |
|
190 iBrowserAppUi->SetBrowserLauncherService( NULL ); |
|
191 } |
|
192 } |
|
193 |
|
194 // ----------------------------------------------------------------------------- |
|
195 // CBrowserLauncherService::DownloadFinished() |
|
196 // ----------------------------------------------------------------------------- |
|
197 // |
|
198 void CBrowserLauncherService::DownloadFinishedL( TInt aReason, const CAiwGenericParamList& aParamList ) |
|
199 { |
|
200 LOG_ENTERFN( "CBrowserLauncherService::DownloadFinishedL" ); |
|
201 |
|
202 // This function is called by the Browser. If download is finished |
|
203 // write the result to the clients buffer. |
|
204 |
|
205 // Get the size of the parameter list`s externalized size. |
|
206 TInt parameterListExternalizedSize = aParamList.Size(); |
|
207 |
|
208 // Create the buffer to hold the externalized data. |
|
209 HBufC8* newClientBuffer = HBufC8::NewL( parameterListExternalizedSize ); |
|
210 delete iClientBuffer; // delete the old buffer |
|
211 iClientBuffer = newClientBuffer; |
|
212 |
|
213 // Create Stream object, and write stream to descriptor iClientBuffer. |
|
214 TPtr8 piClientBuffer = iClientBuffer->Des(); |
|
215 RDesWriteStream writeStream( piClientBuffer ); |
|
216 |
|
217 // Externalize parameter list into descriptor iClientBuffer. |
|
218 aParamList.ExternalizeL( writeStream ); |
|
219 BROWSER_LOG( ( _L( " ExternalizeL OK" ) ) ); |
|
220 |
|
221 // Close stream object. |
|
222 writeStream.CommitL(); |
|
223 BROWSER_LOG( ( _L( " CommitL OK" ) ) ); |
|
224 writeStream.Close(); |
|
225 BROWSER_LOG( ( _L( " Close OK" ) ) ); |
|
226 |
|
227 // Complete the client with the created buffer`s size. |
|
228 if ( aReason == KErrNone ) |
|
229 { |
|
230 TPckg<TInt> bufferSize( iClientBuffer->Length() ); |
|
231 TRAPD(err, iMyAsyncMessage.WriteL( 1, bufferSize )); |
|
232 LOG_WRITE_FORMAT(" WriteL erro code : %d", err ); |
|
233 User::LeaveIfError(err); |
|
234 iMyAsyncMessage.Complete( KErrNone ); |
|
235 } |
|
236 else |
|
237 { |
|
238 iMyAsyncMessage.Complete( aReason ); |
|
239 } |
|
240 } |
|
241 |
|
242 // ----------------------------------------------------------------------------- |
|
243 // CBrowserLauncherService::ConstructL() |
|
244 // ----------------------------------------------------------------------------- |
|
245 // |
|
246 void CBrowserLauncherService::ConstructL() |
|
247 { |
|
248 LOG_ENTERFN( "CBrowserLauncherService::ConstructL" ); |
|
249 iBrowserAppUi->SetBrowserLauncherService( this ); |
|
250 } |
|
251 |
|
252 // End of File |