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