author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Wed, 13 Oct 2010 14:35:16 +0300 | |
branch | RCL_3 |
changeset 71 | a45dccb283c5 |
parent 65 | 8e6fa1719340 |
permissions | -rw-r--r-- |
65 | 1 |
/* |
2 |
* Copyright (c) 2004 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: Handle special load events such as network connection, |
|
15 |
* deal with non-http or non-html requests |
|
16 |
* |
|
17 |
*/ |
|
18 |
||
19 |
||
20 |
// INCLUDE FILES |
|
21 |
#include <browser_platform_variant.hrh> |
|
22 |
#include "BrowserContentView.h" // not used, to be removed |
|
23 |
#include "BrowserSpecialLoadObserver.h" |
|
24 |
#include "BrowserLoadObserver.h" |
|
25 |
#include "logger.h" |
|
26 |
#include "BrowserAppDocument.h" |
|
27 |
#include "ApiProvider.h" |
|
28 |
#include "Preferences.h" |
|
29 |
#include "BrowserUIVariant.hrh" |
|
30 |
#include "Display.h" |
|
31 |
#include "BrowserAppUi.h" |
|
32 |
#include "BrowserWindow.h" |
|
33 |
#include "BrowserWindowManager.h" |
|
34 |
#include "CommonConstants.h" |
|
35 |
#ifdef __WINS__ |
|
36 |
#include <commdb.h> |
|
37 |
#include <aknselectionlist.h> |
|
38 |
#include <AknLists.h> |
|
39 |
#endif // __WINS__ |
|
40 |
#include <DocumentHandler.h> |
|
41 |
#include <mconnection.h> // for MConnection |
|
42 |
#include <schemehandler.h> |
|
43 |
#include <BrowserNG.rsg> |
|
44 |
#include <FeatMgr.h> |
|
45 |
#include <AiwGenericParam.h> |
|
46 |
#include <aknnavi.h> |
|
47 |
||
48 |
//CONSTANTS |
|
49 |
const TInt KMaxDocHandlerUrlLen = 255; |
|
50 |
//DestNetChange |
|
51 |
#include <CmApplicationSettingsUi.h> |
|
52 |
||
53 |
||
54 |
// --------------------------------------------------------- |
|
55 |
// CBrowserSpecialLoadObserver::NewL() |
|
56 |
// --------------------------------------------------------- |
|
57 |
// |
|
58 |
CBrowserSpecialLoadObserver* CBrowserSpecialLoadObserver::NewL( |
|
59 |
MApiProvider& aApiProvider, |
|
60 |
CBrowserWindow* aWindow, |
|
61 |
CEikDocument* aDocument, |
|
62 |
CBrowserContentView* aContentView ) |
|
63 |
{ |
|
64 |
CBrowserSpecialLoadObserver* self = |
|
65 |
new (ELeave) CBrowserSpecialLoadObserver( |
|
66 |
aApiProvider, aWindow, aDocument, aContentView ); |
|
67 |
CleanupStack::PushL( self ); |
|
68 |
self->ConstructL( ); |
|
69 |
CleanupStack::Pop(); // self |
|
70 |
return self; |
|
71 |
} |
|
72 |
||
73 |
// --------------------------------------------------------- |
|
74 |
// CBrowserSpecialLoadObserver::~CBrowserSpecialLoadObserver() |
|
75 |
// --------------------------------------------------------- |
|
76 |
// |
|
77 |
CBrowserSpecialLoadObserver::~CBrowserSpecialLoadObserver() |
|
78 |
{ |
|
79 |
delete iSchemeHandler; |
|
80 |
delete iDocHandler; |
|
81 |
} |
|
82 |
||
83 |
// --------------------------------------------------------- |
|
84 |
// CBrowserSpecialLoadObserver::CBrowserSpecialLoadObserver() |
|
85 |
// --------------------------------------------------------- |
|
86 |
// |
|
87 |
CBrowserSpecialLoadObserver::CBrowserSpecialLoadObserver( |
|
88 |
MApiProvider& aApiProvider, |
|
89 |
CBrowserWindow* aWindow, |
|
90 |
CEikDocument* aDocument, |
|
91 |
CBrowserContentView* aContentView ) : |
|
92 |
iApiProvider( &aApiProvider ), |
|
93 |
iWindow( aWindow ), |
|
94 |
iDocument( aDocument ), |
|
95 |
iSchemeHandler( NULL ), |
|
96 |
iContentView( aContentView ), |
|
97 |
iSchemeProcessing( EFalse ), |
|
98 |
iLongZeroStartup( EFalse ), |
|
99 |
iConnectionStarted( EFalse ) |
|
100 |
{ |
|
101 |
} |
|
102 |
||
103 |
// --------------------------------------------------------- |
|
104 |
// CBrowserSpecialLoadObserver::ConstructL() |
|
105 |
// --------------------------------------------------------- |
|
106 |
// |
|
107 |
void CBrowserSpecialLoadObserver::ConstructL() |
|
108 |
{ |
|
109 |
} |
|
110 |
||
111 |
// --------------------------------------------------------- |
|
112 |
// CBrowserSpecialLoadObserver::NetworkConnectionNeededL() |
|
113 |
// --------------------------------------------------------- |
|
114 |
// |
|
115 |
void CBrowserSpecialLoadObserver::NetworkConnectionNeededL( |
|
116 |
TInt* aConnectionPtr, |
|
117 |
TInt* aSockSvrHandle, |
|
118 |
TBool* aNewConn, |
|
119 |
TApBearerType* aBearerType ) |
|
120 |
{ |
|
121 |
LOG_ENTERFN("CBrowserSpecialLoadObserver::NetworkConnectionNeededL"); |
|
122 |
||
123 |
__ASSERT_DEBUG( (aConnectionPtr != NULL), Util::Panic( Util::EUninitializedData ) ); |
|
124 |
__ASSERT_DEBUG( (aSockSvrHandle != NULL), Util::Panic( Util::EUninitializedData ) ); |
|
125 |
__ASSERT_DEBUG( (aNewConn != NULL), Util::Panic( Util::EUninitializedData ) ); |
|
126 |
__ASSERT_DEBUG( (aBearerType != NULL), Util::Panic( Util::EUninitializedData ) ); |
|
127 |
||
128 |
#ifdef BRDO_OCC_ENABLED_FF |
|
129 |
TBool retryFlag = CBrowserAppUi::Static()->GetRetryFlag(); |
|
130 |
if( retryFlag ) |
|
131 |
{ |
|
132 |
BROWSER_LOG((_L("Retry is in progress"))); |
|
133 |
return; |
|
134 |
} |
|
135 |
#endif |
|
136 |
||
137 |
iApiProvider->SetProgressShown( ETrue ); |
|
138 |
TBool query( EFalse ); |
|
139 |
if( iApiProvider->Connection().Connected() ) |
|
140 |
{ |
|
141 |
TInt a( iWindow->WindowId() ); |
|
142 |
BROWSER_LOG( ( _L( "already connected, WindowId: %d" ), a ) ); |
|
143 |
*aConnectionPtr = (TInt) &iApiProvider->Connection().Connection(); |
|
144 |
*aSockSvrHandle = iApiProvider->Connection().SocketServer().Handle(); |
|
145 |
*aNewConn = EFalse; |
|
71
a45dccb283c5
Revision: 201038
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
65
diff
changeset
|
146 |
#ifdef BRDO_OCC_ENABLED_FF |
a45dccb283c5
Revision: 201038
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
65
diff
changeset
|
147 |
TBool newConnFlag = CBrowserAppUi::Static()->GetNewConnFlag(); |
a45dccb283c5
Revision: 201038
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
65
diff
changeset
|
148 |
if( newConnFlag ) |
a45dccb283c5
Revision: 201038
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
65
diff
changeset
|
149 |
{ |
a45dccb283c5
Revision: 201038
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
65
diff
changeset
|
150 |
*aNewConn = ETrue; |
a45dccb283c5
Revision: 201038
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
65
diff
changeset
|
151 |
BROWSER_LOG((_L("Resetting new conn flag to false"))); |
a45dccb283c5
Revision: 201038
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
65
diff
changeset
|
152 |
CBrowserAppUi::Static()->SetNewConnFlag(EFalse); |
a45dccb283c5
Revision: 201038
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
65
diff
changeset
|
153 |
} |
a45dccb283c5
Revision: 201038
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
65
diff
changeset
|
154 |
#endif |
65 | 155 |
*aBearerType = iApiProvider->Connection().CurrentBearerTypeL(); |
156 |
} |
|
157 |
else |
|
158 |
{ |
|
159 |
BROWSER_LOG((_L("not connected."))); |
|
160 |
*aNewConn = ETrue; |
|
161 |
TBool isValid( EFalse ); |
|
162 |
TUint32 ap( 0 ); |
|
163 |
TInt err( KErrNone ); |
|
164 |
||
165 |
BROWSER_LOG((_L("AP selectionMode: %d."), |
|
166 |
iApiProvider->Preferences().AccessPointSelectionMode() )); |
|
167 |
||
168 |
//determine the type of connection |
|
169 |
switch (iApiProvider->Preferences().AccessPointSelectionMode() ) |
|
170 |
{ |
|
171 |
case EAlwaysAsk: |
|
172 |
{ |
|
173 |
BROWSER_LOG((_L("always ask."))); |
|
174 |
// Always ask |
|
175 |
isValid = ETrue; |
|
176 |
break; |
|
177 |
} |
|
178 |
||
179 |
case EDestination: |
|
180 |
{ |
|
181 |
isValid = ETrue; // force to show LAN connection dialog |
|
182 |
||
183 |
#ifdef __WINS__ |
|
184 |
query = ETrue; // disable connection query dialog |
|
185 |
#endif // __WINS__ |
|
186 |
||
187 |
// for bug fix MLAN-7EKFV4, if bookmark has defined its AP, use it |
|
188 |
if ( iApiProvider->RequestedAp() != KWmlNoDefaultAccessPoint ) |
|
189 |
{ |
|
190 |
#ifndef __WINS__ |
|
191 |
ap = Util::IapIdFromWapIdL( |
|
192 |
*iApiProvider, iApiProvider->RequestedAp() ); |
|
193 |
BROWSER_LOG((_L("ap: %d"), ap)); |
|
194 |
#else // __WINS__ |
|
195 |
// On WINS no need to convert the AP ID |
|
196 |
ap = iApiProvider->RequestedAp(); |
|
197 |
#endif // __WINS__ |
|
198 |
||
199 |
iApiProvider->Connection().SetRequestedAP( ap ); |
|
200 |
iApiProvider->Connection().SetConnectionType( EConnectionMethod ); |
|
201 |
} |
|
202 |
else |
|
203 |
{ |
|
204 |
TUint32 snapId = iApiProvider->Preferences().DefaultSnapId(); |
|
205 |
//connection type is destination nw |
|
206 |
iApiProvider->Connection().SetConnectionType( EDestination ); |
|
207 |
//set snap id |
|
208 |
iApiProvider->Connection().SetRequestedSnap( snapId ); |
|
209 |
} |
|
210 |
break; |
|
211 |
} |
|
212 |
||
213 |
case EConnectionMethod: |
|
214 |
{ |
|
215 |
BROWSER_LOG((_L("user defined."))); |
|
216 |
// User defined |
|
217 |
||
218 |
TRAP( err, isValid = Util::CheckApValidityL( *iApiProvider, |
|
219 |
iApiProvider->RequestedAp() )); |
|
220 |
BROWSER_LOG((_L("isValid 1: %d"), isValid)); |
|
221 |
BROWSER_LOG((_L("err: %d"), err)); |
|
222 |
if( isValid ) |
|
223 |
{ // valid AP, get it |
|
224 |
#ifndef __WINS__ |
|
225 |
ap = Util::IapIdFromWapIdL( |
|
226 |
*iApiProvider, iApiProvider->RequestedAp() ); |
|
227 |
BROWSER_LOG((_L("ap: %d"), ap)); |
|
228 |
#else // __WINS__ |
|
229 |
// On WINS no need to convert the AP ID |
|
230 |
ap = iApiProvider->RequestedAp(); |
|
231 |
#endif // __WINS__ |
|
232 |
} |
|
233 |
else if( err == KErrNone ) |
|
234 |
{ // still try to get AP |
|
235 |
TUint apUid = iApiProvider->Preferences().DefaultAccessPoint(); |
|
236 |
||
237 |
BROWSER_LOG((_L("apUid: %d"), apUid)); |
|
238 |
||
239 |
if ( apUid == KWmlNoDefaultAccessPoint ) |
|
240 |
{ |
|
241 |
#ifdef __WINS__ |
|
242 |
query = ETrue; // disable connection query dialog |
|
243 |
isValid = ETrue; // force to show LAN connection dialog |
|
244 |
#else // __WINS__ |
|
245 |
BROWSER_LOG((_L("StartPrefView."))); |
|
246 |
// there are no AP, show preferences view without always ask |
|
247 |
isValid = iApiProvider->StartPreferencesViewL( EShowDestinations | EShowConnectionMethods ); |
|
248 |
if( isValid ) |
|
249 |
{ |
|
250 |
if( iApiProvider->Preferences().AccessPointSelectionMode() == EConnectionMethod ) |
|
251 |
{ |
|
252 |
ap = iApiProvider->Preferences().DefaultAccessPoint(); |
|
253 |
} |
|
254 |
// else if EDestination, user choosed SNAP in preference view |
|
255 |
} |
|
256 |
#endif // __WINS__ |
|
257 |
} |
|
258 |
} |
|
259 |
||
260 |
//set connection type and AP or SNAP Id |
|
261 |
if( iApiProvider->Preferences().AccessPointSelectionMode() == EDestination ) |
|
262 |
{ |
|
263 |
TUint32 snapId = iApiProvider->Preferences().DefaultSnapId(); |
|
264 |
iApiProvider->Connection().SetConnectionType( EDestination ); |
|
265 |
iApiProvider->Connection().SetRequestedSnap( snapId ); |
|
266 |
} |
|
267 |
else // EConnectionMethod |
|
268 |
{ |
|
269 |
iApiProvider->Connection().SetRequestedAP( ap ); |
|
270 |
iApiProvider->Connection().SetConnectionType( EConnectionMethod ); |
|
271 |
} |
|
272 |
break; |
|
273 |
} |
|
274 |
||
275 |
default: |
|
276 |
{ |
|
277 |
BROWSER_LOG((_L("wrong type of connection"))); |
|
278 |
} |
|
279 |
} //switch |
|
280 |
||
281 |
BROWSER_LOG((_L("isValid 2: %d"), isValid)); |
|
282 |
if( isValid ) |
|
283 |
{ |
|
284 |
iConnectionCancelled = EFalse; |
|
285 |
if( !iApiProvider->Connection().Connected() ) |
|
286 |
{ |
|
287 |
iApiProvider->Connection().SetRequestedAP( ap ); |
|
288 |
||
289 |
TBool startPage = iWindow->LoadObserver().LoadUrlType() == |
|
290 |
CBrowserLoadObserver::ELoadUrlTypeStartPage; |
|
291 |
TBool noConnDlgs = !iApiProvider->Preferences().ShowConnectionDialogs(); |
|
292 |
||
293 |
// Disable connection dialogs if... |
|
294 |
TBool disableConnDlgs = |
|
295 |
query || |
|
296 |
startPage || // ...the load type is StartPage |
|
297 |
noConnDlgs || // ...connection dialogs setting = OFF |
|
298 |
LongZeroStartup(); // ...Browser started with long zero keypress |
|
299 |
SetLongZeroStartup( EFalse ); |
|
300 |
||
301 |
BROWSER_LOG((_L("StartConnection params, query: %d, temp: %d"), query, disableConnDlgs)); |
|
302 |
iConnectionStarted = ETrue; // is true when connection request submited. |
|
303 |
#ifndef __WINS__ |
|
304 |
TUint32 bookmarkIap( 0 ); |
|
305 |
//If bookmark has defined its AP, use it |
|
306 |
if ( iApiProvider->RequestedAp() != KWmlNoDefaultAccessPoint ) |
|
307 |
{ |
|
308 |
bookmarkIap = Util::IapIdFromWapIdL( *iApiProvider, iApiProvider->RequestedAp() ); |
|
309 |
BROWSER_LOG((_L("Bookmark Iap: %d"), bookmarkIap)); |
|
310 |
iApiProvider->Connection().SetRequestedAP( bookmarkIap ); |
|
311 |
iApiProvider->Connection().SetConnectionType( EConnectionMethod ); |
|
312 |
} |
|
313 |
else |
|
314 |
{ |
|
315 |
iApiProvider->Connection().SetRequestedAP( bookmarkIap ); |
|
316 |
BROWSER_LOG((_L("Setting Bookmark Iap: %d"), bookmarkIap)); |
|
317 |
} |
|
318 |
#endif |
|
319 |
// might leave, don't TRAP. OK. |
|
320 |
err = iApiProvider->Connection().StartConnectionL( disableConnDlgs ); |
|
321 |
iConnectionStarted = EFalse; // is false when connection response completed. |
|
322 |
} |
|
323 |
||
324 |
// during StartConnectionL user pressing "Stop" can cancel |
|
325 |
if (iConnectionCancelled) |
|
326 |
{ |
|
327 |
err = KErrCancel; |
|
328 |
} |
|
329 |
BROWSER_LOG((_L("err after StartConnection: %d"), err)); |
|
330 |
||
331 |
if( err == KErrNone ) |
|
332 |
{ |
|
333 |
*aConnectionPtr = (TInt) &iApiProvider->Connection().Connection(); |
|
334 |
*aSockSvrHandle = iApiProvider->Connection().SocketServer().Handle(); |
|
335 |
*aBearerType = iApiProvider->Connection().CurrentBearerTypeL(); |
|
336 |
} |
|
337 |
||
338 |
CBrowserAppUi::Static()->ConnNeededStatusL( err ); |
|
339 |
if (( err == KErrCancel ) && !iApiProvider->IsPageLoaded()) |
|
340 |
{ |
|
341 |
// Close Browser's Content View window if connection setup is cancelled to avoid a blank white screen |
|
342 |
// ** Don't do this is page was previously loaded and is visible to user. |
|
343 |
// ALSO, if feeds are enabled, don't close the window if coming from feeds folder view |
|
344 |
// or in topic or feed views |
|
345 |
||
346 |
// *** Changing back to CloseContentView as a part of the new Browser exit functionality |
|
347 |
#ifdef __RSS_FEEDS |
|
348 |
TUid previousViewID = iApiProvider->LastActiveViewId(); |
|
349 |
if( (previousViewID != KUidBrowserFeedsFolderViewId) && |
|
350 |
(previousViewID != KUidBrowserFeedsTopicViewId) && |
|
351 |
(previousViewID != KUidBrowserFeedsFeedViewId) ) |
|
352 |
{ |
|
353 |
iApiProvider->Display().NaviPaneL()->Pop(); |
|
354 |
CBrowserAppUi::Static()->CloseContentViewL(); |
|
355 |
} |
|
356 |
#else //__RSS_FEEDS |
|
357 |
CBrowserAppUi::Static()->CloseContentViewL(); |
|
358 |
#endif //__RSS_FEEDS |
|
359 |
} |
|
360 |
else if( err == KErrGeneral ) |
|
361 |
{ |
|
362 |
if( !iApiProvider->Preferences().HttpSecurityWarningsStatSupressed() ) |
|
363 |
{ |
|
364 |
iWindow->Display().UpdateSecureIndicatorL( |
|
365 |
EAknIndicatorStateOff ); |
|
366 |
} |
|
367 |
} |
|
368 |
// user might cancel, pass result to BrowserEngine |
|
369 |
User::LeaveIfError( err ); |
|
370 |
iApiProvider->Display().StartProgressAnimationL(); |
|
371 |
} |
|
372 |
else |
|
373 |
{ |
|
374 |
User::LeaveIfError( err ); |
|
375 |
} |
|
376 |
} |
|
377 |
} |
|
378 |
||
379 |
// --------------------------------------------------------- |
|
380 |
// CBrowserSpecialLoadObserver::DoHandleRequestL() |
|
381 |
// --------------------------------------------------------- |
|
382 |
// |
|
383 |
TBool CBrowserSpecialLoadObserver::DoHandleRequestL |
|
384 |
( RArray<TUint>* aTypeArray, CDesCArrayFlat* aDesArray ) |
|
385 |
{ |
|
386 |
LOG_ENTERFN("CBrowserSpecialLoadObserver::HandleRequestL"); |
|
387 |
||
388 |
if( !iSchemeProcessing ) |
|
389 |
{ |
|
390 |
iSchemeProcessing = ETrue; |
|
391 |
TBool paramFound( EFalse ); |
|
392 |
TPtrC requestUrl = ExtractBrCtlParam( |
|
393 |
EParamRequestUrl, |
|
394 |
aTypeArray, |
|
395 |
aDesArray, |
|
396 |
paramFound ); |
|
397 |
__ASSERT_DEBUG( paramFound, Util::Panic( Util::EUninitializedData ) ); |
|
398 |
BROWSER_LOG( ( _L( " EParamRequestUrl: %S" ), &requestUrl ) ); |
|
399 |
||
400 |
// pass to the CSchemaHandler |
|
401 |
CSchemeHandler* newSH = CSchemeHandler::NewL( requestUrl ); |
|
402 |
delete iSchemeHandler; |
|
403 |
iSchemeHandler = newSH; |
|
404 |
BROWSER_LOG( ( _L( " iSchemeHandler OK" ) ) ); |
|
405 |
||
406 |
// construct the current accesspoint |
|
407 |
// if it's connected, always add it |
|
408 |
if ( iApiProvider->Connection().Connected() ) |
|
409 |
{ |
|
410 |
CAiwGenericParamList* paramsList = CAiwGenericParamList::NewL(); |
|
411 |
CleanupStack::PushL(paramsList); |
|
412 |
TInt32 ap = iApiProvider->Connection().CurrentAPId(); |
|
413 |
TAiwVariant paramVariant (ap); |
|
414 |
TAiwGenericParam genericParam( EGenericParamAccessPoint, paramVariant ); |
|
415 |
paramsList->AppendL (genericParam ); |
|
416 |
||
417 |
||
418 |
// set the parameter |
|
419 |
iSchemeHandler->SetParameterList( paramsList ); |
|
420 |
||
421 |
CleanupStack::Pop(); |
|
422 |
} |
|
423 |
||
424 |
iSchemeHandler->Observer( this ); |
|
425 |
iSchemeHandler->HandleUrlEmbeddedL(); |
|
426 |
} |
|
427 |
return ETrue; |
|
428 |
} |
|
429 |
||
430 |
// --------------------------------------------------------- |
|
431 |
// CBrowserSpecialLoadObserver::HandleRequestL() |
|
432 |
// --------------------------------------------------------- |
|
433 |
// |
|
434 |
TBool CBrowserSpecialLoadObserver::HandleRequestL |
|
435 |
( RArray<TUint>* aTypeArray, CDesCArrayFlat* aDesArray ) |
|
436 |
{ |
|
437 |
TBool ret( ETrue ); |
|
438 |
TRAPD( err, DoHandleRequestL( aTypeArray, aDesArray ) ); |
|
439 |
if( KErrNone != err ) |
|
440 |
{ |
|
441 |
iSchemeProcessing = EFalse; |
|
442 |
User::Leave( err ); |
|
443 |
} |
|
444 |
return ret; |
|
445 |
} |
|
446 |
||
447 |
// --------------------------------------------------------- |
|
448 |
// CBrowserSpecialLoadObserver::HandleDownloadL() |
|
449 |
// --------------------------------------------------------- |
|
450 |
// |
|
451 |
TBool CBrowserSpecialLoadObserver::HandleDownloadL |
|
452 |
( RArray<TUint>* aTypeArray, CDesCArrayFlat* aDesArray ) |
|
453 |
{ |
|
454 |
LOG_ENTERFN("CBrowserSpecialLoadObserver::HandleDownloadL"); |
|
455 |
||
456 |
TBool downloadHandled = EFalse; |
|
457 |
||
458 |
#ifdef __RSS_FEEDS |
|
459 |
// Check to see if this is content to be handled by UI (rss or opml) |
|
460 |
// |
|
461 |
if (HandleUiContentL(aTypeArray, aDesArray)) |
|
462 |
{ |
|
463 |
return ETrue; |
|
464 |
} |
|
465 |
#endif // __RSS_FEEDS |
|
466 |
||
467 |
CBrowserAppDocument* appDoc = STATIC_CAST( CBrowserAppDocument*, iDocument ); |
|
468 |
||
469 |
__ASSERT_DEBUG( (appDoc != NULL), Util::Panic( Util::EUninitializedData ) ); |
|
470 |
||
471 |
if ( appDoc->IsContentHandlerRegistered() ) |
|
472 |
{ |
|
473 |
BROWSER_LOG( ( _L( "Calling file handler." ) ) ); |
|
474 |
||
475 |
TBool paramFound( EFalse ); |
|
476 |
TPtrC fileName = ExtractBrCtlParam( |
|
477 |
EParamLocalFileName, |
|
478 |
aTypeArray, |
|
479 |
aDesArray, |
|
480 |
paramFound ); |
|
481 |
__ASSERT_DEBUG( paramFound, Util::Panic( Util::EUninitializedData ) ); |
|
482 |
||
483 |
if ( fileName.Length() == 0 ) |
|
484 |
{ |
|
485 |
// May be a Rights Object download - |
|
486 |
// no downloaded file, nothing to open/handle/pass to BrowserLauncher client. |
|
487 |
BROWSER_LOG( ( _L( " Empty fileName" ) ) ); |
|
488 |
} |
|
489 |
else |
|
490 |
{ |
|
491 |
CAiwGenericParamList* genericParamList = |
|
492 |
BrCtlParamList2GenericParamListL( aTypeArray, aDesArray ); |
|
493 |
CleanupStack::PushL( genericParamList ); |
|
494 |
||
495 |
// Forward the file to the registered handler. |
|
496 |
TBool continueBrowsing( EFalse ); |
|
497 |
downloadHandled = CBrowserAppUi::Static()->HandleContentL |
|
498 |
( fileName, *genericParamList, continueBrowsing ); |
|
499 |
BROWSER_LOG( ( _L( " downloadHandled: %d, continueBrowsing: %d" ), |
|
500 |
downloadHandled, continueBrowsing ) ); |
|
501 |
||
502 |
CleanupStack::PopAndDestroy( genericParamList ); // genericParamList |
|
503 |
||
504 |
if ( downloadHandled ) |
|
505 |
{ |
|
506 |
// We can delete the file now. |
|
507 |
RFs fs; |
|
508 |
User::LeaveIfError( fs.Connect() ); |
|
509 |
CleanupClosePushL( fs ); |
|
510 |
fs.Delete( fileName ); // Return value is ignored. |
|
511 |
CleanupStack::PopAndDestroy( &fs ); // fs |
|
512 |
} |
|
513 |
||
514 |
if ( !continueBrowsing ) |
|
515 |
{ |
|
516 |
iApiProvider->SetExitFromEmbeddedMode( ETrue ); |
|
517 |
} |
|
518 |
} |
|
519 |
} |
|
520 |
else |
|
521 |
{ |
|
522 |
// No handler registered. |
|
523 |
BROWSER_LOG( ( _L( " No handler registered." ) ) ); |
|
524 |
} |
|
525 |
||
526 |
// If the download (file) was not handled, |
|
527 |
// the BrowserUI handles it with Document Handler. |
|
528 |
if ( !downloadHandled ) |
|
529 |
{ |
|
530 |
// This content must be handled by BrowserUI - Browser Control cannot handle it. |
|
531 |
OpenFileEmbeddedL( aTypeArray, aDesArray ); |
|
532 |
downloadHandled = ETrue; |
|
533 |
} |
|
534 |
||
535 |
BROWSER_LOG( ( _L( " downloadHandled: [%d]" ), (TInt)downloadHandled ) ); |
|
536 |
return downloadHandled; |
|
537 |
} |
|
538 |
||
539 |
#ifdef __RSS_FEEDS |
|
540 |
// --------------------------------------------------------- |
|
541 |
// CBrowserSpecialLoadObserver::HandleUiContentL() |
|
542 |
// --------------------------------------------------------- |
|
543 |
// |
|
544 |
TBool CBrowserSpecialLoadObserver::HandleUiContentL( |
|
545 |
RArray<TUint>* aTypeArray, |
|
546 |
CDesCArrayFlat* aDesArray ) const |
|
547 |
{ |
|
548 |
TDataType dataType; |
|
549 |
||
550 |
TBool contentTypeFound( EFalse ); |
|
551 |
TBool urlFound( EFalse ); |
|
552 |
TBool fileFound( EFalse ); |
|
553 |
TBool result( EFalse ); |
|
554 |
||
555 |
TPtrC receivedContentType = ExtractBrCtlParam( |
|
556 |
EParamReceivedContentType, |
|
557 |
aTypeArray, |
|
558 |
aDesArray, |
|
559 |
contentTypeFound ); |
|
560 |
||
561 |
TPtrC url = ExtractBrCtlParam( |
|
562 |
EParamRequestUrl, |
|
563 |
aTypeArray, |
|
564 |
aDesArray, |
|
565 |
urlFound ); |
|
566 |
||
567 |
||
568 |
TPtrC fileName = ExtractBrCtlParam( |
|
569 |
EParamLocalFileName, |
|
570 |
aTypeArray, |
|
571 |
aDesArray, |
|
572 |
fileFound ); |
|
573 |
||
574 |
// Compare returns 0 if the strings are the same |
|
575 |
if ((receivedContentType.Compare(KMimeTypeAppXML) == 0) || |
|
576 |
(receivedContentType.Compare(KMimeTypeTextXML) == 0) || |
|
577 |
(receivedContentType.Compare(KMimeTypeRSS) == 0) || |
|
578 |
(receivedContentType.Compare(KMimeTypeAtom) == 0) || |
|
579 |
(receivedContentType.Compare(KMimeTypeRDF) == 0) || |
|
580 |
(receivedContentType.Compare(KOPMLMimeType) == 0) || |
|
581 |
//++PK added check for Text/xml content-type, only T is in caps, should make string check case insensitive |
|
582 |
(receivedContentType.Compare(KMimeTypeCapsTextXML) == 0) |
|
583 |
//++PK |
|
584 |
) |
|
585 |
{ |
|
586 |
if (fileFound) |
|
587 |
{ |
|
588 |
RFs rfs; |
|
589 |
RFile rfile; |
|
590 |
||
591 |
// Open the file. |
|
592 |
User::LeaveIfError(rfs.Connect()); |
|
593 |
CleanupClosePushL(rfs); |
|
594 |
||
595 |
TInt fileResult( rfile.Open( rfs, fileName, EFileRead ) ); |
|
596 |
// file open doesn't succeeded |
|
597 |
User::LeaveIfError( fileResult ); |
|
598 |
if( fileResult == KErrNone ) |
|
599 |
{ |
|
600 |
CleanupClosePushL( rfile ); |
|
601 |
||
602 |
TBuf<KMaxDataTypeLength> dataTypeDes; |
|
603 |
TBool deleteOpml = EFalse; |
|
604 |
||
605 |
if(CBrowserAppUi::Static()->RecognizeUiFileL(rfile, dataTypeDes)) |
|
606 |
{ |
|
607 |
TFileName fileNameBuf = TFileName(fileName); |
|
608 |
TFileName truncFileName; |
|
609 |
User::LeaveIfError( rfile.Name(truncFileName) ); |
|
610 |
||
611 |
// Confirm with user that we want to handle it |
|
612 |
if(CBrowserAppUi::Static()->ConfirmUiHandlingL(truncFileName, dataTypeDes)) |
|
613 |
{ |
|
614 |
// Have AppUI decide what to do with it, what view, etc. |
|
615 |
CBrowserAppUi::Static()->HandleUiDownloadL(fileNameBuf, dataTypeDes); |
|
616 |
} |
|
617 |
else |
|
618 |
{ |
|
619 |
deleteOpml = ETrue; |
|
620 |
} |
|
621 |
result = ETrue; |
|
622 |
} |
|
623 |
||
624 |
||
625 |
// delete the downloaded file if it is not handled |
|
626 |
if(deleteOpml && (dataTypeDes.Compare(KOPMLMimeType) == 0 )) |
|
627 |
{ |
|
628 |
rfs.Delete(fileName); |
|
629 |
} |
|
630 |
} |
|
631 |
||
632 |
// If open file was handled, skip sending to feeds engine |
|
633 |
// otherwise, pass it on |
|
634 |
if(!result) |
|
635 |
{ |
|
636 |
TInt fileSize; |
|
637 |
// Read the file from the beginning into a buffer |
|
638 |
User::LeaveIfError(rfile.Size(fileSize)); |
|
639 |
HBufC8* buffer = HBufC8::NewLC(fileSize); |
|
640 |
TPtr8 bufferPtr(buffer->Des()); |
|
641 |
TInt startPos = 0; |
|
642 |
User::LeaveIfError(rfile.Read(startPos, bufferPtr, fileSize)); |
|
643 |
||
644 |
_LIT8( searchTag1, "<feed" ); //Atom 1.0 Feed |
|
645 |
_LIT8( searchTag2, "<rdf" ); //RSS 1.0 Feed |
|
646 |
_LIT8( searchTag3, "<rss" ); //RSS 2.0 Feed |
|
647 |
||
648 |
if( ( bufferPtr.FindF( searchTag1 ) != KErrNotFound ) || (bufferPtr.FindF( searchTag2 ) != KErrNotFound ) || |
|
649 |
(bufferPtr.FindF( searchTag3 ) != KErrNotFound ) ) |
|
650 |
{ |
|
651 |
// Launch the Feeds Engine only when xml file contain atleast one of the above mentioned feeds tag |
|
652 |
iContentView->HandleSubscribeToWithUrlL(url); |
|
653 |
} |
|
654 |
else |
|
655 |
{ |
|
656 |
//Delete the file, if it is not fwd to Feeds Engine, As displaying of xml files is not supported. |
|
657 |
rfs.Delete(fileName); |
|
658 |
} |
|
659 |
result = ETrue; |
|
660 |
CleanupStack::PopAndDestroy(); //buffer |
|
661 |
} |
|
662 |
||
663 |
CleanupStack::PopAndDestroy(); //rfile |
|
664 |
CleanupStack::PopAndDestroy(); //rfs |
|
665 |
} |
|
666 |
} |
|
667 |
||
668 |
return result; |
|
669 |
} |
|
670 |
||
671 |
#endif // __RSS_FEEDS |
|
672 |
||
673 |
||
674 |
// --------------------------------------------------------- |
|
675 |
// CBrowserSpecialLoadObserver::BrCtlParamList2GenericParamListL() |
|
676 |
// --------------------------------------------------------- |
|
677 |
// |
|
678 |
CAiwGenericParamList* CBrowserSpecialLoadObserver::BrCtlParamList2GenericParamListL( |
|
679 |
RArray<TUint>* aTypeArray, |
|
680 |
CDesCArrayFlat* aDesArray ) const |
|
681 |
{ |
|
682 |
LOG_ENTERFN("CBrowserSpecialLoadObserver::BrCtlParamList2GenericParamListL"); |
|
683 |
||
684 |
__ASSERT_DEBUG( (aTypeArray != NULL), Util::Panic( Util::EUninitializedData ) ); |
|
685 |
__ASSERT_DEBUG( (aDesArray != NULL), Util::Panic( Util::EUninitializedData ) ); |
|
686 |
||
687 |
||
688 |
//Creating generic param list |
|
689 |
CAiwGenericParamList* genericParamList = CAiwGenericParamList::NewLC(); |
|
690 |
||
691 |
for( TInt j = 0; j < aTypeArray->Count(); j++ ) |
|
692 |
{ |
|
693 |
BROWSER_LOG( ( _L( " iter: %d" ), j ) ); |
|
694 |
TBool paramFound( EFalse ); |
|
695 |
const TUint paramType = (*aTypeArray)[j]; |
|
696 |
TPtrC param = ExtractBrCtlParam( |
|
697 |
paramType, |
|
698 |
aTypeArray, |
|
699 |
aDesArray, |
|
700 |
paramFound ); |
|
701 |
__ASSERT_DEBUG( paramFound, Util::Panic( Util::EUninitializedData ) ); |
|
702 |
||
703 |
BROWSER_LOG( ( _L( " Type: %d, Value: %S" ), paramType, ¶m ) ); |
|
704 |
||
705 |
switch( paramType ) |
|
706 |
{ |
|
707 |
case EParamRequestUrl: |
|
708 |
{ |
|
709 |
BROWSER_LOG( ( _L( " EParamRequestUrl" ) ) ); |
|
710 |
// limit url to 255 char's or DocHandler panics! |
|
711 |
TAiwVariant paramVariant( param.Left( KMaxDocHandlerUrlLen ) ); |
|
712 |
TAiwGenericParam genericParam( EGenericParamURL, |
|
713 |
paramVariant ); |
|
714 |
genericParamList->AppendL( genericParam ); |
|
715 |
break; |
|
716 |
} |
|
717 |
case EParamRealm: |
|
718 |
{ |
|
719 |
BROWSER_LOG( ( _L( " EParamRealm" ) ) ); |
|
720 |
// No corresponding generic param! |
|
721 |
break; |
|
722 |
} |
|
723 |
case EParamUsername: |
|
724 |
{ |
|
725 |
BROWSER_LOG( ( _L( " EParamUsername" ) ) ); |
|
726 |
// No corresponding generic param! |
|
727 |
break; |
|
728 |
} |
|
729 |
case EParamPassword: |
|
730 |
{ |
|
731 |
BROWSER_LOG( ( _L( " EParamPassword" ) ) ); |
|
732 |
// No corresponding generic param! |
|
733 |
break; |
|
734 |
} |
|
735 |
case EParamProxyUsername: |
|
736 |
{ |
|
737 |
BROWSER_LOG( ( _L( " EParamProxyUsername" ) ) ); |
|
738 |
// No corresponding generic param! |
|
739 |
break; |
|
740 |
} |
|
741 |
case EParamProxyPassword: |
|
742 |
{ |
|
743 |
BROWSER_LOG( ( _L( " EParamProxyPassword" ) ) ); |
|
744 |
// No corresponding generic param! |
|
745 |
break; |
|
746 |
} |
|
747 |
case EParamRawRequestHeader: |
|
748 |
{ |
|
749 |
BROWSER_LOG( ( _L( " EParamRawRequestHeader" ) ) ); |
|
750 |
// No corresponding generic param! |
|
751 |
break; |
|
752 |
} |
|
753 |
case EParamReceivedContentType: |
|
754 |
{ |
|
755 |
BROWSER_LOG( ( _L( " EParamReceivedContentType" ) ) ); |
|
756 |
// The expected content type should override the response header's |
|
757 |
// content type => don't use EParamReceivedContentType if |
|
758 |
// EParamExpectedContentType is set! |
|
759 |
TBool expectedContentTypeFound( EFalse ); |
|
760 |
ExtractBrCtlParam( |
|
761 |
EParamExpectedContentType, |
|
762 |
aTypeArray, |
|
763 |
aDesArray, |
|
764 |
expectedContentTypeFound ); |
|
765 |
if ( !expectedContentTypeFound ) |
|
766 |
{ |
|
767 |
// Using EParamReceivedContentType |
|
768 |
BROWSER_LOG( ( _L( " EParamExpectedContentType not found" ) ) ); |
|
769 |
TAiwVariant paramVariant( param ); |
|
770 |
TAiwGenericParam genericParam( EGenericParamMIMEType, |
|
771 |
paramVariant ); |
|
772 |
genericParamList->AppendL( genericParam ); |
|
773 |
} |
|
774 |
break; |
|
775 |
} |
|
776 |
case EParamExpectedContentType: |
|
777 |
{ |
|
778 |
// Overrides EParamReceivedContentType! |
|
779 |
BROWSER_LOG( ( _L( " EParamExpectedContentType" ) ) ); |
|
780 |
TAiwVariant paramVariant( param ); |
|
781 |
TAiwGenericParam genericParam( EGenericParamMIMEType, |
|
782 |
paramVariant ); |
|
783 |
genericParamList->AppendL( genericParam ); |
|
784 |
break; |
|
785 |
} |
|
786 |
case EParamTotalContentLength: |
|
787 |
{ |
|
788 |
BROWSER_LOG( ( _L( " EParamTotalContentLength" ) ) ); |
|
789 |
// No corresponding generic param! |
|
790 |
break; |
|
791 |
} |
|
792 |
case EParamReceivedContent: |
|
793 |
{ |
|
794 |
BROWSER_LOG( ( _L( " EParamReceivedContent" ) ) ); |
|
795 |
// No corresponding generic param! |
|
796 |
break; |
|
797 |
} |
|
798 |
case EParamRawResponseHeader: |
|
799 |
{ |
|
800 |
BROWSER_LOG( ( _L( " EParamRawResponseHeader" ) ) ); |
|
801 |
// No corresponding generic param! |
|
802 |
break; |
|
803 |
} |
|
804 |
case EParamLocalFileName: |
|
805 |
{ |
|
806 |
BROWSER_LOG( ( _L( " EParamLocalFileName" ) ) ); |
|
807 |
TAiwVariant paramVariant( param ); |
|
808 |
TAiwGenericParam genericParam( EGenericParamFile, |
|
809 |
paramVariant ); |
|
810 |
genericParamList->AppendL( genericParam ); |
|
811 |
break; |
|
812 |
} |
|
813 |
case EParamCharset: |
|
814 |
{ |
|
815 |
BROWSER_LOG( ( _L( " EParamCharset" ) ) ); |
|
816 |
TAiwVariant paramVariant( param ); |
|
817 |
TAiwGenericParam genericParam( EGenericParamCharSet, |
|
818 |
paramVariant ); |
|
819 |
genericParamList->AppendL( genericParam ); |
|
820 |
break; |
|
821 |
} |
|
822 |
case EParamRefererHeader: |
|
823 |
{ |
|
824 |
BROWSER_LOG( ( _L( " EParamRefererHeader" ) ) ); |
|
825 |
TAiwVariant paramVariant( param ); |
|
826 |
TAiwGenericParam genericParam( EGenericParamReferringURI, |
|
827 |
paramVariant ); |
|
828 |
genericParamList->AppendL( genericParam ); |
|
829 |
break; |
|
830 |
} |
|
831 |
default: |
|
832 |
{ |
|
833 |
BROWSER_LOG( ( _L( " Unexpected argument" ) ) ); |
|
834 |
break; |
|
835 |
} |
|
836 |
} |
|
837 |
} |
|
838 |
||
839 |
// Always add the access point, if currently connected |
|
840 |
if( iApiProvider->Connection().Connected() ) |
|
841 |
{ |
|
842 |
TInt32 ap = iApiProvider->Connection().CurrentAPId(); |
|
843 |
BROWSER_LOG( ( _L( " IAP: %d" ), ap ) ); |
|
844 |
TAiwVariant paramVariant( ap ); |
|
845 |
TAiwGenericParam genericParam( EGenericParamAccessPoint, |
|
846 |
paramVariant ); |
|
847 |
genericParamList->AppendL( genericParam ); |
|
848 |
} |
|
849 |
||
850 |
CleanupStack::Pop( genericParamList ); // genericParamList |
|
851 |
return genericParamList; |
|
852 |
} |
|
853 |
||
854 |
// --------------------------------------------------------- |
|
855 |
// CBrowserSpecialLoadObserver::ExtractBrCtlParam() |
|
856 |
// --------------------------------------------------------- |
|
857 |
// |
|
858 |
TPtrC CBrowserSpecialLoadObserver::ExtractBrCtlParam |
|
859 |
( TUint aParamTypeToFind, |
|
860 |
RArray<TUint>* aTypeArray, |
|
861 |
CDesCArrayFlat* aDesArray, |
|
862 |
TBool& aParamFound ) const |
|
863 |
{ |
|
864 |
LOG_ENTERFN("CBrowserSpecialLoadObserver::ExtractBrCtlParam"); |
|
865 |
||
866 |
__ASSERT_DEBUG( (aTypeArray != NULL), Util::Panic( Util::EUninitializedData ) ); |
|
867 |
__ASSERT_DEBUG( (aDesArray != NULL), Util::Panic( Util::EUninitializedData ) ); |
|
868 |
||
869 |
// initialize output parameter |
|
870 |
aParamFound = EFalse; |
|
871 |
TPtrC16 retParamValue; |
|
872 |
||
873 |
for( TInt j = 0; j < aTypeArray->Count(); j++ ) |
|
874 |
{ |
|
875 |
BROWSER_LOG( ( _L( " iter: %d" ), j ) ); |
|
876 |
const TUint paramType = (*aTypeArray)[j]; |
|
877 |
if ( aParamTypeToFind == paramType ) |
|
878 |
{ |
|
879 |
// That's we need |
|
880 |
retParamValue.Set( aDesArray->MdcaPoint(j) ); |
|
881 |
aParamFound = ETrue; // Indicate it in the out param |
|
882 |
BROWSER_LOG( ( _L( " Type: %d, Value: %S" ), paramType, &retParamValue ) ); |
|
883 |
break; // break the loop - we found it |
|
884 |
} |
|
885 |
} |
|
886 |
||
887 |
return retParamValue; |
|
888 |
} |
|
889 |
||
890 |
// --------------------------------------------------------- |
|
891 |
// CBrowserSpecialLoadObserver::IsSelfDownloadContentTypeL() |
|
892 |
// --------------------------------------------------------- |
|
893 |
// |
|
894 |
TBool CBrowserSpecialLoadObserver::IsSelfDownloadContentTypeL |
|
895 |
( RArray<TUint>* aTypeArray, |
|
896 |
CDesCArrayFlat* aDesArray ) const |
|
897 |
{ |
|
898 |
LOG_ENTERFN("CBrowserSpecialLoadObserver::IsSelfDownloadContentTypeL"); |
|
899 |
||
900 |
TBool isSelfDownloadContentType = EFalse; |
|
901 |
||
902 |
// First get the download's content type (mime type) |
|
903 |
TBool paramFound( EFalse ); |
|
904 |
TPtrC contentType = ExtractBrCtlParam( |
|
905 |
EParamReceivedContentType, |
|
906 |
aTypeArray, |
|
907 |
aDesArray, |
|
908 |
paramFound ); |
|
909 |
||
910 |
if ( !paramFound ) |
|
911 |
{ |
|
912 |
isSelfDownloadContentType = EFalse; |
|
913 |
} |
|
914 |
else |
|
915 |
{ |
|
916 |
BROWSER_LOG( ( _L( " contentType: [%S]" ), &contentType ) ); |
|
917 |
// Then check, if it is in SelfDownloadContentTypes |
|
918 |
TInt cTLength = contentType.Length(); |
|
919 |
TPtrC selfDownloadCTs = iApiProvider->Preferences().SelfDownloadContentTypesL(); |
|
920 |
TInt idx = KErrNotFound; |
|
921 |
idx = selfDownloadCTs.FindF( contentType ); |
|
922 |
const TChar KBrowserSpecLoadObsSemicolon = ';'; |
|
923 |
while( idx != KErrNotFound ) |
|
924 |
{ |
|
925 |
// check for ';' on the left KSemicolon |
|
926 |
if ( idx == 0 || selfDownloadCTs[ idx - 1 ] == KBrowserSpecLoadObsSemicolon ) |
|
927 |
{ |
|
928 |
// check for ';' on the right |
|
929 |
idx += cTLength; |
|
930 |
if ( idx == selfDownloadCTs.Length() || selfDownloadCTs[ idx ] == KBrowserSpecLoadObsSemicolon ) |
|
931 |
{ |
|
932 |
isSelfDownloadContentType = ETrue; |
|
933 |
break; |
|
934 |
} |
|
935 |
} |
|
936 |
selfDownloadCTs.Set( selfDownloadCTs.Mid( idx ) ); |
|
937 |
idx = selfDownloadCTs.FindF( contentType ); |
|
938 |
} |
|
939 |
} |
|
940 |
||
941 |
BROWSER_LOG( ( _L( " isSelfDownloadContentType: %d" ), isSelfDownloadContentType ) ); |
|
942 |
return isSelfDownloadContentType; |
|
943 |
} |
|
944 |
||
945 |
// --------------------------------------------------------- |
|
946 |
// CBrowserSpecialLoadObserver::OpenFileEmbeddedL() |
|
947 |
// --------------------------------------------------------- |
|
948 |
// |
|
949 |
void CBrowserSpecialLoadObserver::OpenFileEmbeddedL |
|
950 |
( RArray<TUint>* aTypeArray, |
|
951 |
CDesCArrayFlat* aDesArray ) |
|
952 |
{ |
|
953 |
LOG_ENTERFN("CBrowserSpecialLoadObserver::OpenFileEmbeddedL"); |
|
954 |
||
955 |
CDocumentHandler* newDocHandler = CDocumentHandler::NewL(); |
|
956 |
delete iDocHandler; |
|
957 |
iDocHandler = newDocHandler; |
|
958 |
iDocHandler->SetExitObserver( this ); |
|
959 |
||
960 |
TBool paramFound( EFalse ); |
|
961 |
TPtrC fileName = ExtractBrCtlParam( |
|
962 |
EParamLocalFileName, |
|
963 |
aTypeArray, |
|
964 |
aDesArray, |
|
965 |
paramFound ); |
|
966 |
__ASSERT_DEBUG( paramFound, Util::Panic( Util::EUninitializedData ) ); |
|
967 |
||
968 |
TPtrC contentType = ExtractBrCtlParam( |
|
969 |
EParamReceivedContentType, |
|
970 |
aTypeArray, |
|
971 |
aDesArray, |
|
972 |
paramFound ); |
|
973 |
HBufC8* contentType8 = 0; |
|
974 |
if ( !paramFound ) |
|
975 |
{ |
|
976 |
contentType8 = KNullDesC8().AllocLC(); |
|
977 |
} |
|
978 |
else |
|
979 |
{ |
|
980 |
BROWSER_LOG( ( _L( " contentType: [%S]" ), &contentType ) ); |
|
981 |
contentType8 = HBufC8::NewLC( contentType.Length() ); |
|
982 |
// 16 bit buffer copied into 8 bit buffer. |
|
983 |
contentType8->Des().Copy( contentType ); |
|
984 |
} |
|
985 |
TDataType dataType( *contentType8 ); |
|
986 |
||
987 |
CAiwGenericParamList* genericParamList = |
|
988 |
BrCtlParamList2GenericParamListL( aTypeArray, aDesArray ); |
|
989 |
CleanupStack::PushL( genericParamList ); |
|
990 |
||
991 |
// File is not yet saved to target folder. |
|
992 |
TBool allowSave( ETrue ); |
|
993 |
TAiwVariant allowSaveVariant( allowSave ); |
|
994 |
TAiwGenericParam genericParamAllowSave |
|
995 |
( EGenericParamAllowSave, allowSaveVariant ); |
|
996 |
genericParamList->AppendL( genericParamAllowSave ); |
|
997 |
||
998 |
// Set EGenericParamAllowMove - we encourage handlers to apply |
|
999 |
// move instead of copy for the file. |
|
1000 |
TBool allowMove( ETrue ); |
|
1001 |
TAiwVariant allowMoveVariant( allowMove ); |
|
1002 |
TAiwGenericParam genericParamAllowMove |
|
1003 |
( EGenericParamAllowMove, allowMoveVariant ); |
|
1004 |
genericParamList->AppendL( genericParamAllowMove ); |
|
1005 |
||
1006 |
RFile tempFile; |
|
1007 |
iDocHandler->OpenTempFileL( fileName, tempFile ); |
|
1008 |
CleanupClosePushL( tempFile ); |
|
1009 |
/*TInt err = */iDocHandler->OpenFileEmbeddedL( tempFile, |
|
1010 |
dataType, |
|
1011 |
*genericParamList ); |
|
1012 |
//BROWSER_LOG( ( _L( " err: %d" ), err ) ); |
|
1013 |
CleanupStack::PopAndDestroy( &tempFile ); // tempFile |
|
1014 |
||
1015 |
CleanupStack::PopAndDestroy( genericParamList ); // genericParamList |
|
1016 |
CleanupStack::PopAndDestroy( contentType8 ); // contentType8 |
|
1017 |
} |
|
1018 |
||
1019 |
// --------------------------------------------------------- |
|
1020 |
// CBrowserSpecialLoadObserver::HandleServerAppExit() |
|
1021 |
// --------------------------------------------------------- |
|
1022 |
// |
|
1023 |
void CBrowserSpecialLoadObserver::HandleServerAppExit( TInt /*aReason*/ ) |
|
1024 |
{ |
|
1025 |
iSchemeProcessing = EFalse; |
|
1026 |
} |
|
1027 |
||
1028 |
#ifdef __WINS__ |
|
1029 |
// ---------------------------------------------------------------------------- |
|
1030 |
// CBrowserSpecialLoadObserver::AskIapIdL(TUint32& aId) |
|
1031 |
// Ask IAP id from the user |
|
1032 |
// ---------------------------------------------------------------------------- |
|
1033 |
// |
|
1034 |
TInt CBrowserSpecialLoadObserver::AskIapIdL( TUint32& aId ) |
|
1035 |
{ |
|
1036 |
CCommsDatabase* TheDb; |
|
1037 |
TInt res; |
|
1038 |
TBuf<40> name; |
|
1039 |
TUint32 id; |
|
1040 |
RArray<TUint32> idArray; |
|
1041 |
CDesCArrayFlat* items = new (ELeave) CDesCArrayFlat(16); |
|
1042 |
CleanupStack::PushL( items ); // 1 |
|
1043 |
||
1044 |
// Get IAP names and ids from the database |
|
1045 |
TheDb = CCommsDatabase::NewL( EDatabaseTypeIAP ); |
|
1046 |
CleanupStack::PushL( TheDb ); // 2 |
|
1047 |
||
1048 |
TheDb->ShowHiddenRecords(); |
|
1049 |
||
1050 |
CCommsDbTableView* view = TheDb->OpenTableLC( TPtrC( IAP ) ); // 3 |
|
1051 |
res = view->GotoFirstRecord(); |
|
1052 |
||
1053 |
while( !res ) |
|
1054 |
{ |
|
1055 |
view->ReadTextL( TPtrC( COMMDB_NAME ), name ); |
|
1056 |
view->ReadUintL( TPtrC( COMMDB_ID ), id ); |
|
1057 |
||
1058 |
idArray.Insert( id, 0 ); |
|
1059 |
items->InsertL( 0, name ); |
|
1060 |
||
1061 |
res = view->GotoNextRecord(); |
|
1062 |
RDebug::Print(_L("IAP name, id: %S, %d"), &name, id ); |
|
1063 |
} |
|
1064 |
||
1065 |
// Create listbox and PUSH it. |
|
1066 |
CEikTextListBox* list = new (ELeave) CAknSinglePopupMenuStyleListBox; |
|
1067 |
CleanupStack::PushL( list ); // 4 |
|
1068 |
||
1069 |
// Create popup list and PUSH it. |
|
1070 |
CAknPopupList* popupList = CAknPopupList::NewL( |
|
1071 |
list, R_AVKON_SOFTKEYS_OK_EMPTY__OK, |
|
1072 |
AknPopupLayouts::EMenuWindow); |
|
1073 |
CleanupStack::PushL( popupList ); // 5 |
|
1074 |
||
1075 |
// initialize listbox. |
|
1076 |
list->ConstructL(popupList, CEikListBox::ELeftDownInViewRect); |
|
1077 |
list->CreateScrollBarFrameL(ETrue); |
|
1078 |
list->ScrollBarFrame()->SetScrollBarVisibilityL( |
|
1079 |
CEikScrollBarFrame::EOff, |
|
1080 |
CEikScrollBarFrame::EAuto); |
|
1081 |
||
1082 |
// Set listitems. |
|
1083 |
CTextListBoxModel* model = list->Model(); |
|
1084 |
model->SetItemTextArray( items ); |
|
1085 |
model->SetOwnershipType( ELbmOwnsItemArray ); |
|
1086 |
||
1087 |
// Set title |
|
1088 |
popupList->SetTitleL( _L( "Select IAP:" ) ); |
|
1089 |
||
1090 |
// Show popup list. |
|
1091 |
TInt popupOk = popupList->ExecuteLD(); |
|
1092 |
if( popupOk ) |
|
1093 |
{ |
|
1094 |
TInt index = list->CurrentItemIndex(); |
|
1095 |
aId = idArray[index]; |
|
1096 |
} |
|
1097 |
||
1098 |
CleanupStack::Pop( popupList ); // popuplist |
|
1099 |
CleanupStack::PopAndDestroy( list ); // list |
|
1100 |
CleanupStack::PopAndDestroy( view ); // view |
|
1101 |
CleanupStack::PopAndDestroy( TheDb ); // TheDb |
|
1102 |
CleanupStack::Pop( items ); // items CTextListBoxModel* model owns it |
|
1103 |
||
1104 |
idArray.Close(); |
|
1105 |
items = NULL; |
|
1106 |
return popupOk; |
|
1107 |
} |
|
1108 |
||
1109 |
#endif // __WINS__ |
|
1110 |
||
1111 |
// End of file |