|
1 /* |
|
2 * Copyright (c) 2006, 2008 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 * |
|
16 */ |
|
17 |
|
18 #include <apmrec.h> |
|
19 #include <apgcli.h> |
|
20 #include <eikappui.h> |
|
21 #include <eikenv.h> |
|
22 #include <eikbtgpc.h> |
|
23 #include <StringLoader.h> |
|
24 #include <WidgetUi.rsg> |
|
25 #include <avkon.hrh> |
|
26 #include <aknmessagequerydialog.h> |
|
27 #include <ActiveApDb.h> |
|
28 #include <EscapeUtils.h> |
|
29 #include <Uri16.h> |
|
30 #include <BrCtlDefs.h> |
|
31 #include "WidgetUiObserver.h" |
|
32 #include "WidgetUiWindow.h" |
|
33 #include "WidgetUiWindowView.h" |
|
34 #include "WidgetUiWindowManager.h" |
|
35 #include "WidgetUiWindowContainer.h" |
|
36 |
|
37 #ifndef RD_PF_SEC_APPARC |
|
38 #include <genericparam.h> |
|
39 #else |
|
40 #ifndef __BROWSER_SDK |
|
41 #include "AiwGenericParam.h" |
|
42 #endif |
|
43 #endif |
|
44 |
|
45 // EXTERNAL DATA STRUCTURES |
|
46 |
|
47 // EXTERNAL FUNCTION PROTOTYPES |
|
48 |
|
49 // CONSTANTS |
|
50 _LIT( KFileScheme, "file://" ); |
|
51 _LIT( KDefaultDrivePath, "C:\\" ); |
|
52 _LIT( KPathChar, "\\" ); |
|
53 _LIT( KLprojExt, ".lproj" ); |
|
54 |
|
55 // MACROS |
|
56 |
|
57 // LOCAL CONSTANTS AND MACROS |
|
58 |
|
59 // MODULE DATA STRUCTURES |
|
60 |
|
61 // LOCAL FUNCTION PROTOTYPES |
|
62 TInt doTakeSnapshot( TAny* ptr ); |
|
63 |
|
64 // FORWARD DECLARATIONS |
|
65 |
|
66 // ============================= LOCAL FUNCTIONS =============================== |
|
67 |
|
68 |
|
69 // ============================ MEMBER FUNCTIONS =============================== |
|
70 |
|
71 // ----------------------------------------------------------------------------- |
|
72 // CWidgetUiObserver::UpdateBrowserVScrollBarL |
|
73 // ----------------------------------------------------------------------------- |
|
74 // |
|
75 void CWidgetUiObserver::UpdateBrowserVScrollBarL( |
|
76 TInt aDocumentHeight, |
|
77 TInt aDisplayHeight, |
|
78 TInt aDisplayPosY ) |
|
79 { |
|
80 (void)aDocumentHeight; |
|
81 (void)aDisplayHeight; |
|
82 (void)aDisplayPosY; |
|
83 #ifdef _DEBUG |
|
84 _LIT(KUpdateScrollbar, "Document height = %d, Display height = %d, Display pos = %d"); |
|
85 |
|
86 if ( iCanLog ) |
|
87 { |
|
88 iFileLogger.WriteFormat( KUpdateScrollbar, aDocumentHeight, aDisplayHeight, aDisplayPosY ); |
|
89 } |
|
90 #endif |
|
91 } |
|
92 |
|
93 // ----------------------------------------------------------------------------- |
|
94 // CWidgetUiObserver::UpdateBrowserHScrollBarL |
|
95 // ----------------------------------------------------------------------------- |
|
96 // |
|
97 void CWidgetUiObserver::UpdateBrowserHScrollBarL( |
|
98 TInt aDocumentWidth, |
|
99 TInt aDisplayWidth, |
|
100 TInt aDisplayPosX ) |
|
101 { |
|
102 (void)aDocumentWidth; |
|
103 (void)aDisplayWidth; |
|
104 (void)aDisplayPosX; |
|
105 #ifdef _DEBUG |
|
106 _LIT(KUpdateScrollbar, "Document width = %d, Display width = %d, Display pos = %d"); |
|
107 |
|
108 if ( iCanLog ) |
|
109 { |
|
110 iFileLogger.WriteFormat( KUpdateScrollbar, aDocumentWidth, aDisplayWidth, aDisplayPosX ); |
|
111 } |
|
112 #endif |
|
113 } |
|
114 |
|
115 // ----------------------------------------------------------------------------- |
|
116 // CWidgetUiObserver::NotifyLayoutChange |
|
117 // ----------------------------------------------------------------------------- |
|
118 // |
|
119 void CWidgetUiObserver::NotifyLayoutChange( TBrCtlLayout aNewLayout ) |
|
120 { |
|
121 (void)aNewLayout; |
|
122 #ifdef _DEBUG |
|
123 _LIT(KUpdateLayout, "New layout is %d"); |
|
124 RDebug::Printf("CWidgetUiObserver::NotifyLayoutChange - beginning"); |
|
125 if ( iCanLog ) |
|
126 { |
|
127 iFileLogger.WriteFormat( KUpdateLayout, aNewLayout) ; |
|
128 } |
|
129 #endif |
|
130 if( iWindow->WidgetMiniViewState() == EPublishStart ) |
|
131 { |
|
132 //iWindow->PublishSnapShot(); |
|
133 iCollectBitmapTimer->Cancel(); |
|
134 iCollectBitmapTimer->Start(TCallBack(&doTakeSnapshot,iWindow)); |
|
135 } |
|
136 } |
|
137 TInt doTakeSnapshot( TAny* ptr ) |
|
138 { |
|
139 RDebug::Printf("CWidgetUiObserver::doTakeSnapshot"); |
|
140 static_cast<CWidgetUiWindow*>(ptr)->PublishSnapShot(); |
|
141 return EFalse; |
|
142 } |
|
143 |
|
144 // ----------------------------------------------------------------------------- |
|
145 // CWidgetUiObserver::UpdateTitle |
|
146 // ----------------------------------------------------------------------------- |
|
147 // |
|
148 void CWidgetUiObserver::UpdateTitleL( const TDesC& /*aTitle*/ ) |
|
149 { |
|
150 } |
|
151 |
|
152 // ----------------------------------------------------------------------------- |
|
153 // CWidgetUiObserver::UpdateSoftkeyL |
|
154 // ----------------------------------------------------------------------------- |
|
155 // |
|
156 void CWidgetUiObserver::UpdateSoftkeyL( TBrCtlKeySoftkey aKeySoftkey, |
|
157 const TDesC& aLabel, |
|
158 TUint32 /*aCommandId*/, |
|
159 TBrCtlSoftkeyChangeReason aBrCtlSoftkeyChangeReason ) |
|
160 { |
|
161 // ignore idle reason. this comes when brctl calls for default softkey update |
|
162 if(aBrCtlSoftkeyChangeReason != EChangeReasonIdle) |
|
163 { |
|
164 if (aKeySoftkey == EKeyRight && aLabel.Length() == 0) |
|
165 { |
|
166 //reset right softkey to "Exit" |
|
167 if (!iSoftkeyExitStr) |
|
168 { |
|
169 iSoftkeyExitStr = StringLoader::LoadL( R_WIDGETUI_SOFTKEY_EXIT ); |
|
170 } |
|
171 iWindow->SetSoftKeyLabelL( aKeySoftkey, *iSoftkeyExitStr ); |
|
172 } |
|
173 else if (aKeySoftkey == EKeyLeft && aLabel.Length() == 0) |
|
174 { |
|
175 if (!iLeftSoftkeyStr) |
|
176 { |
|
177 iLeftSoftkeyStr = StringLoader::LoadL(R_WIDGETUI_SOFTKEY_OPTION); |
|
178 } |
|
179 iWindow->SetSoftKeyLabelL( aKeySoftkey, *iLeftSoftkeyStr ); |
|
180 } |
|
181 else |
|
182 { |
|
183 iWindow->SetSoftKeyLabelL( aKeySoftkey, aLabel ); |
|
184 } |
|
185 } |
|
186 } |
|
187 |
|
188 // ----------------------------------------------------------------------------- |
|
189 // CWidgetUiObserver::HandleBrowserLoadEventL |
|
190 // ----------------------------------------------------------------------------- |
|
191 // |
|
192 void CWidgetUiObserver::HandleBrowserLoadEventL( |
|
193 TBrCtlDefs::TBrCtlLoadEvent aLoadEvent, |
|
194 TUint /*aSize*/, |
|
195 TUint16 /*aTransactionId*/ ) |
|
196 { |
|
197 if (aLoadEvent == TBrCtlDefs::EEventLoadFinished) |
|
198 { |
|
199 iWindow->SetWidgetLoaded(ETrue); |
|
200 } |
|
201 } |
|
202 |
|
203 // ----------------------------------------------------------------------------- |
|
204 // CWidgetUiObserver::ResolveEmbeddedLinkL |
|
205 // ----------------------------------------------------------------------------- |
|
206 // |
|
207 TBool CWidgetUiObserver::ResolveEmbeddedLinkL(const TDesC& aEmbeddedUrl, |
|
208 const TDesC& aCurrentUrl, |
|
209 TBrCtlLoadContentType aLoadContentType, |
|
210 MBrCtlLinkContent& aEmbeddedLinkContent) |
|
211 { |
|
212 (void)aCurrentUrl; |
|
213 (void)aLoadContentType; |
|
214 #ifdef _DEBUG |
|
215 _LIT(KResolveEmbeddedLink, "Resolve embedded link aEmbeddedUrl = :%s:, aCurrentUrl = :%s:, aLoadContentType = %d"); |
|
216 |
|
217 if ( iCanLog ) |
|
218 { |
|
219 iFileLogger.WriteFormat( KResolveEmbeddedLink, aEmbeddedUrl, aCurrentUrl, aLoadContentType ); |
|
220 } |
|
221 #endif |
|
222 if ( IsFileScheme( aEmbeddedUrl ) ) |
|
223 { |
|
224 |
|
225 // DENY if accessing anything inside WidgetUI's private dir AND that file is not inside |
|
226 // the widget's own "sandbox". We define an installed widget's "sandbox" to be anything |
|
227 // under e:/private/10282822/<widget ID>/ |
|
228 |
|
229 // Convert URL form to a more friendly path form, with locale-specific subdirectory |
|
230 TFileName lprojName; |
|
231 iWindow->WindowManager().WidgetUIClientSession().GetLprojName( lprojName ); |
|
232 TranslateURLToFilenameL( aEmbeddedUrl, lprojName ); |
|
233 |
|
234 // TRUE if e:/private/10282822/*/* was requested. It may or may not be inside a widget's sandbox. |
|
235 TBool isInsidePrivateDir = ( iFileName && ( (*iFileName).FindF(iAppPrivatePath) == KMaxDriveName ) ) ? ETrue : EFalse; |
|
236 |
|
237 HBufC* widgetPath = iWindow->WidgetPath(); // The widget's sandbox. Object not ours. |
|
238 // TRUE if e:/private/10282822/<widgetID>/foo.js was requested. This is INSIDE widget's sandbox |
|
239 TBool isSandboxed = ( iFileName && widgetPath && (*iFileName).FindF( *widgetPath ) == 0 ) ? ETrue : EFalse; |
|
240 |
|
241 if ( isInsidePrivateDir && !isSandboxed ) |
|
242 { //Acess denied! |
|
243 User::Leave(KErrAccessDenied); |
|
244 } |
|
245 |
|
246 if ( !isSandboxed ) |
|
247 { // For files in Public areas, don't use localized subdirectory |
|
248 TranslateURLToFilenameL( aEmbeddedUrl, KNullDesC); |
|
249 } |
|
250 |
|
251 HBufC8* buf = ReadFileL( *iFileName); |
|
252 |
|
253 if ( !buf && isSandboxed ) |
|
254 { // In case of failure, fall-back to generic/non-localized content |
|
255 TranslateURLToFilenameL( aEmbeddedUrl, KNullDesC ); |
|
256 buf = ReadFileL( *iFileName); |
|
257 } |
|
258 |
|
259 if ( !buf ) |
|
260 { |
|
261 User::Leave(KErrGeneral); |
|
262 } |
|
263 |
|
264 CleanupStack::PushL( buf ); |
|
265 HBufC* contentType = NULL; |
|
266 TPtrC p( NULL, 0 ); |
|
267 contentType = RecognizeLC( *iFileName, *buf ); |
|
268 aEmbeddedLinkContent.HandleResolveComplete( *contentType, p, buf ); |
|
269 CleanupStack::PopAndDestroy( 2, buf ); // contentType, buf |
|
270 return ETrue; |
|
271 } |
|
272 |
|
273 return EFalse; |
|
274 } |
|
275 |
|
276 // ----------------------------------------------------------------------------- |
|
277 // CWidgetUiObserver::ResolveLinkL |
|
278 // ----------------------------------------------------------------------------- |
|
279 // |
|
280 TBool CWidgetUiObserver::ResolveLinkL( const TDesC& aUrl, const TDesC& aCurrentUrl, |
|
281 MBrCtlLinkContent& aBrCtlLinkContent ) |
|
282 { |
|
283 (void)aCurrentUrl; |
|
284 #ifdef _DEBUG |
|
285 _LIT(KResolveLink, "Resolve embedded link aUrl = :%s:, aCurrentUrl = :%s:"); |
|
286 |
|
287 if ( iCanLog ) |
|
288 { |
|
289 iFileLogger.WriteFormat( KResolveLink, aUrl, aCurrentUrl ); |
|
290 } |
|
291 #endif |
|
292 //Re-use existing logic upstairs to enforce inter-widget (and intra WidgetUI) security policies. |
|
293 return ResolveEmbeddedLinkL(aUrl, aCurrentUrl, ELoadContentTypeAny, aBrCtlLinkContent); |
|
294 } |
|
295 |
|
296 // ----------------------------------------------------------------------------- |
|
297 // CWidgetUiObserver::CancelAll |
|
298 // ----------------------------------------------------------------------------- |
|
299 // |
|
300 void CWidgetUiObserver::CancelAll() |
|
301 { |
|
302 #ifdef _DEBUG |
|
303 _LIT(KCancelAll, "All requests canceled"); |
|
304 |
|
305 if ( iCanLog ) |
|
306 { |
|
307 iFileLogger.WriteFormat( KCancelAll ); |
|
308 } |
|
309 #endif |
|
310 } |
|
311 |
|
312 // ----------------------------------------------------------------------------- |
|
313 // CWidgetUiObserver::CWidgetUiObserver() |
|
314 // ----------------------------------------------------------------------------- |
|
315 // |
|
316 CWidgetUiObserver::CWidgetUiObserver( CWidgetUiWindow& aWindow ) |
|
317 : iWindow( &aWindow ), |
|
318 iFileName( NULL ) |
|
319 { |
|
320 } |
|
321 |
|
322 // ----------------------------------------------------------------------------- |
|
323 // CWidgetUiObserver::ConstructL |
|
324 // ----------------------------------------------------------------------------- |
|
325 // |
|
326 void CWidgetUiObserver::ConstructL() |
|
327 { |
|
328 #ifdef _DEBUG |
|
329 _LIT(KDir, "WidgetUi"); |
|
330 _LIT(KFile, "WidgetUi.log"); |
|
331 TInt err( 0 ); |
|
332 |
|
333 err = iFileLogger.Connect(); |
|
334 if ( err == KErrNone ) |
|
335 { |
|
336 iFileLogger.CreateLog( KDir(), KFile(), EFileLoggingModeOverwrite ); |
|
337 iCanLog = ETrue; |
|
338 } |
|
339 #endif |
|
340 |
|
341 iHandler = CDocumentHandler::NewL( CEikonEnv::Static()->Process() ) ; |
|
342 // Get WidgetUI's private directory (e.g. c:/private/10282822/) |
|
343 iCollectBitmapTimer = CIdle::NewL(CActive::EPriorityLow); |
|
344 } |
|
345 |
|
346 // ----------------------------------------------------------------------------- |
|
347 // CWidgetUiObserver::~CWidgetUiObserver |
|
348 // ----------------------------------------------------------------------------- |
|
349 // |
|
350 CWidgetUiObserver::~CWidgetUiObserver() |
|
351 { |
|
352 |
|
353 #ifdef _DEBUG |
|
354 if ( iCanLog ) |
|
355 { |
|
356 iFileLogger.CloseLog(); |
|
357 iFileLogger.Close(); |
|
358 } |
|
359 #endif |
|
360 delete iFileName; |
|
361 delete iHandler; |
|
362 delete iSoftkeyExitStr; |
|
363 delete iLeftSoftkeyStr; |
|
364 delete iCollectBitmapTimer; |
|
365 } |
|
366 |
|
367 // ----------------------------------------------------------------------------- |
|
368 // CWidgetUiObserver::NewL |
|
369 // ----------------------------------------------------------------------------- |
|
370 // |
|
371 CWidgetUiObserver* CWidgetUiObserver::NewL( CWidgetUiWindow& aWindow ) |
|
372 { |
|
373 CWidgetUiObserver* self = new(ELeave)CWidgetUiObserver( aWindow ); |
|
374 CleanupStack::PushL(self); |
|
375 self->ConstructL(); |
|
376 CleanupStack::Pop(1, self); |
|
377 |
|
378 return self; |
|
379 } |
|
380 |
|
381 // ----------------------------------------------------------------------------- |
|
382 // CWidgetUiObserver::IsFileScheme |
|
383 // ----------------------------------------------------------------------------- |
|
384 // |
|
385 TBool CWidgetUiObserver::IsFileScheme( const TDesC& aFileName ) |
|
386 { |
|
387 if ( aFileName.Length()> 0 && aFileName.Ptr() ) |
|
388 { |
|
389 if ( aFileName.FindF(KFileScheme) == 0 ) |
|
390 { |
|
391 return ETrue; |
|
392 } |
|
393 else |
|
394 {//Check for paths are that not URI, but of the form.. |
|
395 // c:/dir/foo.txt. This is to accomodate browser engine inconsistencies. |
|
396 TUriParser16 parser; |
|
397 if( parser.Parse( aFileName ) == KErrNone ) |
|
398 { |
|
399 TPtrC16 scheme = parser.Extract( EUriScheme ); |
|
400 // As per the URI RFC, the part before : is the Scheme |
|
401 if ( scheme.Length() == (KMaxDriveName-1) ) |
|
402 { |
|
403 return ETrue; |
|
404 } |
|
405 } |
|
406 } |
|
407 } |
|
408 |
|
409 return EFalse; |
|
410 } |
|
411 |
|
412 // ----------------------------------------------------------------------------- |
|
413 // CWidgetUiObserver::ReadFile |
|
414 // ----------------------------------------------------------------------------- |
|
415 // |
|
416 HBufC8* CWidgetUiObserver::ReadFileL( const TDesC& aFileName ) |
|
417 { |
|
418 RFile file; |
|
419 |
|
420 if (KErrNone != file.Open( CCoeEnv::Static()->FsSession(), aFileName, EFileRead ) ) |
|
421 { |
|
422 return NULL; |
|
423 } |
|
424 |
|
425 CleanupClosePushL( file ); |
|
426 |
|
427 TInt size; |
|
428 User::LeaveIfError( file.Size( size ) ); |
|
429 HBufC8* buf = HBufC8::NewLC( size ); |
|
430 TPtr8 bufPtr( buf->Des() ); |
|
431 User::LeaveIfError( file.Read( bufPtr ) ); |
|
432 CleanupStack::Pop( buf ); |
|
433 CleanupStack::PopAndDestroy( &file ); |
|
434 return buf; |
|
435 } |
|
436 |
|
437 // ----------------------------------------------------------------------------- |
|
438 // CWidgetUiObserver::RecognizeL |
|
439 // ----------------------------------------------------------------------------- |
|
440 // |
|
441 HBufC* CWidgetUiObserver::RecognizeLC( const TDesC& aFileName, const TDesC8& aData ) |
|
442 { |
|
443 TDataRecognitionResult dataType; |
|
444 RApaLsSession apaSession; |
|
445 TInt ret; |
|
446 HBufC* contentTypeString = KNullDesC().AllocL(); |
|
447 |
|
448 CleanupClosePushL(apaSession); |
|
449 User::LeaveIfError( apaSession.Connect() ); |
|
450 |
|
451 // Ask the application architecture to find the file type |
|
452 ret = apaSession.RecognizeData( aFileName, aData, dataType ); |
|
453 apaSession.Close(); |
|
454 CleanupStack::PopAndDestroy(1, &apaSession); |
|
455 |
|
456 if ( ret == KErrNone && |
|
457 ( dataType.iConfidence == CApaDataRecognizerType::ECertain ) || |
|
458 ( dataType.iConfidence == CApaDataRecognizerType::EProbable ) ) |
|
459 { |
|
460 // If the file type was found, try to match it to a known file type |
|
461 TPtrC8 mimeTypePtr = dataType.iDataType.Des8(); |
|
462 TInt len = mimeTypePtr.Length() + 1; |
|
463 contentTypeString = HBufC::NewL( len ); |
|
464 contentTypeString->Des().Copy( mimeTypePtr ); |
|
465 contentTypeString->Des().ZeroTerminate(); |
|
466 } |
|
467 |
|
468 CleanupStack::PushL( contentTypeString ); |
|
469 |
|
470 return contentTypeString; |
|
471 } |
|
472 |
|
473 // ----------------------------------------------------------------------------- |
|
474 // CWidgetUiObserver::TranslateURLToFilenameL |
|
475 // Translate the file name from a URL to a valid file name in the system. |
|
476 // ----------------------------------------------------------------------------- |
|
477 // |
|
478 TBool CWidgetUiObserver::TranslateURLToFilenameL( const TDesC& aFileName, const TDesC& aLanguageDir ) |
|
479 { |
|
480 // This function accepts URLs in the following format: |
|
481 // file://filename.xxx |
|
482 // file:///filename.xxx |
|
483 // file://c:/filename.xxx |
|
484 // file:///c:/filename.xxx |
|
485 // c:/dir/file.txt (the browser engine can send these too!) |
|
486 TInt count( 0 ); |
|
487 TInt index( 0 ); |
|
488 TBool drvLetter = EFalse; |
|
489 TUint16 c; |
|
490 |
|
491 HBufC* decodedUrl = EscapeUtils::EscapeDecodeL(aFileName); |
|
492 CleanupStack::PushL( decodedUrl ); |
|
493 |
|
494 // Throw away the intial file:// part, if present |
|
495 TPtrC urlPtr( aFileName ); |
|
496 if (urlPtr.FindF( KFileScheme) == 0 ) |
|
497 { |
|
498 urlPtr.Set( decodedUrl->Mid( KFileScheme().Length() ) ); |
|
499 } |
|
500 |
|
501 // Make sure there are enough characters in the filename before |
|
502 // trying to check them |
|
503 count = urlPtr.Length() + aLanguageDir.Length() + KLprojExt().Length() + KPathChar().Length(); |
|
504 if ( urlPtr.Length() > 0 ) //do nothing for trivial input |
|
505 { |
|
506 // Skip the first '/' if there is one |
|
507 if ( urlPtr[0] == '/' ) |
|
508 { |
|
509 urlPtr.Set( urlPtr.Mid( 1 ) ); |
|
510 } |
|
511 // Is there a drive letter? |
|
512 if ( urlPtr.Length() > 1 ) |
|
513 { |
|
514 // Can check for drive letter |
|
515 if ( urlPtr[1 + index] == ':' ) |
|
516 { |
|
517 drvLetter = ETrue; |
|
518 } |
|
519 } |
|
520 if ( drvLetter == EFalse ) |
|
521 { |
|
522 // Plan for a c:\ type drive prefix to what we already tallied above |
|
523 count += KDefaultDrivePath().Length(); |
|
524 } |
|
525 delete iFileName; |
|
526 iFileName = NULL; |
|
527 iFileName = HBufC::NewL( count ); |
|
528 if ( !drvLetter ) |
|
529 { |
|
530 iFileName->Des().Append( KDefaultDrivePath ); |
|
531 } |
|
532 |
|
533 TBool fragment( EFalse ); |
|
534 // Convert relative path containing /./ and /../ to absolute path |
|
535 for ( ; index < urlPtr.Length() && !fragment; index ++ ) |
|
536 { |
|
537 switch ( urlPtr[index] ) |
|
538 { |
|
539 case '#': // Check if there is a fragment '#' |
|
540 { |
|
541 fragment = ETrue; |
|
542 continue; // Just stop there |
|
543 } |
|
544 |
|
545 case '/': |
|
546 { |
|
547 iFileName->Des().Append( KPathChar ); |
|
548 break; |
|
549 } |
|
550 case '.': |
|
551 { |
|
552 if ( index > 1 && urlPtr[index - 1] == '/' ) |
|
553 { |
|
554 if ( index < count - 1 && urlPtr[ index + 1 ] == '/' ) |
|
555 { |
|
556 index ++; // Skip ./ |
|
557 break; |
|
558 } |
|
559 if ( index > 2 && index < count - 3 && |
|
560 urlPtr[ index + 1 ] == '.' && urlPtr[ index + 2 ] == '/' ) |
|
561 { |
|
562 TInt i = index - 2; |
|
563 |
|
564 for ( ; i > 0 && urlPtr[i] != '/'; i-- ) {} // Skip /../ |
|
565 |
|
566 iFileName->Des().SetLength( iFileName->Des().Length() - (index - i) ); |
|
567 index += 2; |
|
568 break; |
|
569 } |
|
570 } |
|
571 } |
|
572 // No break |
|
573 //lint -fallthrough |
|
574 |
|
575 default: |
|
576 { |
|
577 c = urlPtr[ index ]; |
|
578 iFileName->Des().Append( &c, 1 ); |
|
579 break; |
|
580 } |
|
581 } // end of switch |
|
582 } |
|
583 |
|
584 if ( aLanguageDir.Length() ) |
|
585 { |
|
586 TChar backSlash = '\\'; |
|
587 TInt pos = iFileName->Des().LocateReverse( backSlash ); |
|
588 if ( pos != KErrNotFound ) |
|
589 { |
|
590 TPtr p = iFileName->Des(); |
|
591 p.Insert(pos, KLprojExt ); |
|
592 p.Insert(pos, aLanguageDir ); |
|
593 p.Insert(pos, KPathChar ); |
|
594 } |
|
595 } |
|
596 } //Do nothing for any trivial input |
|
597 CleanupStack::PopAndDestroy(1, decodedUrl); // decodedUrl |
|
598 return ETrue; |
|
599 } |
|
600 |
|
601 // ----------------------------------------------------------------------------- |
|
602 // CWidgetUiObserver::NewDownloadL |
|
603 // ----------------------------------------------------------------------------- |
|
604 // |
|
605 TBool CWidgetUiObserver::NewDownloadL( TUint aTransactionID, |
|
606 const TDesC& aFileName, |
|
607 const TDesC& aContentType, |
|
608 const TDesC& aUrl ) |
|
609 { |
|
610 (void)aTransactionID; |
|
611 (void)aFileName; |
|
612 (void)aContentType; |
|
613 (void)aUrl; |
|
614 #ifdef _DEBUG |
|
615 _LIT(KNewDownload1L, "New Download with Trans ID %d, Local filename :%s:"); |
|
616 _LIT(KNewDownload2L, "New Download with Trans ID %d, Content Type :%s:"); |
|
617 _LIT(KNewDownload3L, "New Download with Trans ID %d, URL :%s:"); |
|
618 |
|
619 if ( iCanLog ) |
|
620 { |
|
621 iFileLogger.WriteFormat( KNewDownload1L, aTransactionID, aFileName.Ptr() ); |
|
622 iFileLogger.WriteFormat( KNewDownload2L, aTransactionID, aContentType.Ptr() ); |
|
623 iFileLogger.WriteFormat( KNewDownload3L, aTransactionID, aUrl.Ptr() ); |
|
624 } |
|
625 #endif |
|
626 |
|
627 return ETrue; |
|
628 } |
|
629 |
|
630 // ----------------------------------------------------------------------------- |
|
631 // CWidgetUiObserver::HandleDownloadEventL |
|
632 // ----------------------------------------------------------------------------- |
|
633 // |
|
634 void CWidgetUiObserver::HandleDownloadEventL( TUint aTransactionID, |
|
635 TBrCtlDownloadEvent aDownloadEvent, |
|
636 TUint aValue ) |
|
637 { |
|
638 (void)aTransactionID; |
|
639 (void)aDownloadEvent; |
|
640 (void)aValue; |
|
641 #ifdef _DEBUG |
|
642 _LIT(KDownloadEvent, "Download Event with Trans ID %d, Event %d, Value %d"); |
|
643 if ( iCanLog ) |
|
644 { |
|
645 iFileLogger.WriteFormat( KDownloadEvent, aTransactionID, aDownloadEvent, aValue ); |
|
646 } |
|
647 #endif |
|
648 } |
|
649 |
|
650 // ----------------------------------------------------------------------------- |
|
651 // CWidgetUiObserver::OpenWindowL |
|
652 // ----------------------------------------------------------------------------- |
|
653 // |
|
654 CBrCtlInterface* CWidgetUiObserver::OpenWindowL(TDesC& /*aUrl*/, TDesC* /*aTargetName*/, TBool /*aUserInitiated*/, TAny* /*aReserved*/) |
|
655 { |
|
656 return NULL; |
|
657 } |
|
658 |
|
659 // ----------------------------------------------------------------------------- |
|
660 // CWidgetUiObserver::FindWindowL |
|
661 // ----------------------------------------------------------------------------- |
|
662 // |
|
663 CBrCtlInterface* CWidgetUiObserver::FindWindowL( const TDesC& /*aTargetName*/ ) const |
|
664 { |
|
665 return NULL; |
|
666 } |
|
667 |
|
668 // ----------------------------------------------------------------------------- |
|
669 // CWidgetUiObserver::HandleWindowCommandL |
|
670 // ----------------------------------------------------------------------------- |
|
671 // |
|
672 void CWidgetUiObserver::HandleWindowCommandL( const TDesC& aTargetName, TBrCtlWindowCommand aCommand ) |
|
673 { |
|
674 if( aTargetName == KNullDesC() && aCommand == ECloseWindow) |
|
675 { |
|
676 // prevent background widget from closing active window |
|
677 if (iWindow == iWindow->WindowManager().ActiveWindow()) |
|
678 { |
|
679 iWindow->WindowManager().CloseWindowsAsync(EFalse); // close active window |
|
680 } |
|
681 } |
|
682 } |
|
683 |
|
684 // End of File |