| 3 |      1 | /*
 | 
|  |      2 | * Copyright (c) 2006 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:  BrCtlApiTest
 | 
|  |     15 | *
 | 
|  |     16 | */
 | 
|  |     17 | 
 | 
|  |     18 | // INCLUDE FILES
 | 
|  |     19 | #include <apmrec.h>
 | 
|  |     20 | #include <apgcli.h>
 | 
|  |     21 | #include <eikappui.h>
 | 
|  |     22 | #include <eikenv.h>
 | 
|  |     23 | #include <eikbtgpc.h>
 | 
|  |     24 | #include "BrCtlApiTestObserver.h"
 | 
|  |     25 | #include <avkon.hrh>
 | 
|  |     26 | #include <aknmessagequerydialog.h>
 | 
|  |     27 | 
 | 
|  |     28 | #ifndef RD_PF_SEC_APPARC
 | 
|  |     29 | //#include <genericparam.h>  
 | 
|  |     30 | #else
 | 
|  |     31 | #include "AiwGenericParam.h"
 | 
|  |     32 | #endif
 | 
|  |     33 | 
 | 
|  |     34 | 
 | 
|  |     35 | // ================= MEMBER FUNCTIONS =======================
 | 
|  |     36 | 
 | 
|  |     37 | // ---------------------------------------------------------
 | 
|  |     38 | // CBrCtlApiTestObserver::UpdateBrowserVScrollBarL
 | 
|  |     39 | // ---------------------------------------------------------
 | 
|  |     40 | //
 | 
|  |     41 | void CBrCtlApiTestObserver::UpdateBrowserVScrollBarL(TInt /* aDocumentHeight */, 
 | 
|  |     42 |                                       TInt /* aDisplayHeight */,
 | 
|  |     43 |                                       TInt /* aDisplayPosY */ ) 
 | 
|  |     44 |     {
 | 
|  |     45 |     }
 | 
|  |     46 | 
 | 
|  |     47 | // ---------------------------------------------------------
 | 
|  |     48 | // CBrCtlApiTestObserver::UpdateBrowserHScrollBarL
 | 
|  |     49 | // ---------------------------------------------------------
 | 
|  |     50 | //
 | 
|  |     51 | void CBrCtlApiTestObserver::UpdateBrowserHScrollBarL(TInt /* aDocumentWidth */, 
 | 
|  |     52 |                                       TInt /* aDisplayWidth */,
 | 
|  |     53 |                                       TInt /* aDisplayPosX */ ) 
 | 
|  |     54 |     {
 | 
|  |     55 |     }
 | 
|  |     56 | 
 | 
|  |     57 | // ---------------------------------------------------------
 | 
|  |     58 | // CBrCtlApiTestObserver::NotifyLayoutChange
 | 
|  |     59 | // ---------------------------------------------------------
 | 
|  |     60 | //
 | 
|  |     61 | void CBrCtlApiTestObserver::NotifyLayoutChange( TBrCtlLayout /* aNewLayout */) 
 | 
|  |     62 |     {
 | 
|  |     63 |     }
 | 
|  |     64 | 
 | 
|  |     65 | // ---------------------------------------------------------
 | 
|  |     66 | // CBrCtlSampleAppLayoutObserver::UpdateTitle
 | 
|  |     67 | // ---------------------------------------------------------
 | 
|  |     68 | //
 | 
|  |     69 | void CBrCtlApiTestObserver::UpdateTitleL( const TDesC& /*aTitle*/ )
 | 
|  |     70 |     {
 | 
|  |     71 |     }
 | 
|  |     72 | 
 | 
|  |     73 | // ---------------------------------------------------------
 | 
|  |     74 | // CBrCtlApiTestObserver::UpdateSoftkeyL
 | 
|  |     75 | // ---------------------------------------------------------
 | 
|  |     76 | //
 | 
|  |     77 | void CBrCtlApiTestObserver::UpdateSoftkeyL(TBrCtlKeySoftkey /* aKeySoftkey */,
 | 
|  |     78 |                             const TDesC& /* aLabel */,
 | 
|  |     79 |                             TUint32 /* aCommandId */,
 | 
|  |     80 |                             TBrCtlSoftkeyChangeReason /* aBrCtlSoftkeyChangeReason */) 
 | 
|  |     81 |     {
 | 
|  |     82 |     return; 
 | 
|  |     83 |     }
 | 
|  |     84 | 
 | 
|  |     85 | // ---------------------------------------------------------
 | 
|  |     86 | // CBrCtlApiTestObserver::NetworkConnectionNeededL
 | 
|  |     87 | // ---------------------------------------------------------
 | 
|  |     88 | //
 | 
|  |     89 | void CBrCtlApiTestObserver::NetworkConnectionNeededL(TInt* /*aConnectionPtr*/,
 | 
|  |     90 |                                       TInt* /*aSockSvrHandle*/,
 | 
|  |     91 |                                       TBool* /*aNewConn*/,
 | 
|  |     92 |                                       TApBearerType* /*aBearerType*/) 
 | 
|  |     93 |     {
 | 
|  |     94 |     }
 | 
|  |     95 | 
 | 
|  |     96 | // ---------------------------------------------------------
 | 
|  |     97 | // CBrCtlApiTestObserver::HandleRequestL
 | 
|  |     98 | // ---------------------------------------------------------
 | 
|  |     99 | //
 | 
|  |    100 | TBool CBrCtlApiTestObserver::HandleRequestL(RArray<TUint>* aTypeArray, CDesCArrayFlat* aDesArray) 
 | 
|  |    101 |     {
 | 
|  |    102 | 
 | 
|  |    103 |     TInt i;
 | 
|  |    104 | 	
 | 
|  |    105 |     // The 2 arrays must be in sync. Each element in iTypeArray 
 | 
|  |    106 |     // identifies the type of the corresponding element in iDesArray.
 | 
|  |    107 |     if( aTypeArray->Count() != aDesArray->Count() )
 | 
|  |    108 |         {
 | 
|  |    109 |         User::Leave( KErrArgument );
 | 
|  |    110 |         }
 | 
|  |    111 | 
 | 
|  |    112 | 	// get url
 | 
|  |    113 |     HBufC* url = NULL;
 | 
|  |    114 |     // Serach url in the param list
 | 
|  |    115 |     for(i = 0; i < aTypeArray->Count(); i++)
 | 
|  |    116 |         {
 | 
|  |    117 |         if( (*aTypeArray)[i] == EParamRequestUrl )
 | 
|  |    118 |             {
 | 
|  |    119 |             // the url is found
 | 
|  |    120 |             url = HBufC::NewLC( (*aDesArray)[i].Length() );
 | 
|  |    121 |             url->Des().Copy( (*aDesArray)[i] );
 | 
|  |    122 |             break;
 | 
|  |    123 |             }
 | 
|  |    124 |         }
 | 
|  |    125 |     if( !url )
 | 
|  |    126 |         {
 | 
|  |    127 |         // The url wasn't found. 
 | 
|  |    128 |         User::Leave( KErrArgument );
 | 
|  |    129 |         }
 | 
|  |    130 | 
 | 
|  |    131 | 	// get referrer header
 | 
|  |    132 |     HBufC* refererHeader = NULL;
 | 
|  |    133 |     // Serach url in the param list
 | 
|  |    134 |     for( i = 0; i < aTypeArray->Count(); i++ )
 | 
|  |    135 |         {
 | 
|  |    136 |         if( (*aTypeArray)[i] == EParamRefererHeader )
 | 
|  |    137 |             {
 | 
|  |    138 |             // the referer Header is found
 | 
|  |    139 |             refererHeader = HBufC::NewLC( (*aDesArray)[i].Length() );
 | 
|  |    140 |             refererHeader->Des().Copy( (*aDesArray)[i] );
 | 
|  |    141 |             break;
 | 
|  |    142 |             }
 | 
|  |    143 |         }
 | 
|  |    144 | 
 | 
|  |    145 |     if( refererHeader )
 | 
|  |    146 | 		{
 | 
|  |    147 | 			CleanupStack::PopAndDestroy( 1 ); // refererHeader
 | 
|  |    148 | 		}
 | 
|  |    149 | 
 | 
|  |    150 |     CleanupStack::PopAndDestroy( 1 ); // url
 | 
|  |    151 | 
 | 
|  |    152 |     return ETrue;
 | 
|  |    153 |     }
 | 
|  |    154 | 
 | 
|  |    155 | // ---------------------------------------------------------
 | 
|  |    156 | // CBrCtlApiTestObserver::HandleDownloadL
 | 
|  |    157 | // ---------------------------------------------------------
 | 
|  |    158 | //
 | 
|  |    159 | TBool CBrCtlApiTestObserver::HandleDownloadL(RArray<TUint>* aTypeArray, CDesCArrayFlat* aDesArray)
 | 
|  |    160 |     {
 | 
|  |    161 |     TInt i = 0;
 | 
|  |    162 |     TInt count = aTypeArray->Count();
 | 
|  |    163 |     for (i = 0; i < count; i++)
 | 
|  |    164 |         {
 | 
|  |    165 |         if ((*aTypeArray)[i] == EParamLocalFileName && aDesArray[i].Length() > 0)
 | 
|  |    166 |             {
 | 
|  |    167 |             TInt j = 0;
 | 
|  |    168 |             for (j = 0; j < count; j++)
 | 
|  |    169 |                 {
 | 
|  |    170 |                 if ((*aTypeArray)[j] == EParamReceivedContentType)
 | 
|  |    171 |                     {
 | 
|  |    172 |                     HBufC8* dataType8 = HBufC8::NewLC((*aDesArray)[j].Length());
 | 
|  |    173 |                     dataType8->Des().Copy((*aDesArray)[j]);
 | 
|  |    174 |                     TDataType dataType(*dataType8);
 | 
|  |    175 |                     iHandler->OpenFileEmbeddedL((*aDesArray)[i], dataType);
 | 
|  |    176 |                     CleanupStack::PopAndDestroy();
 | 
|  |    177 |                     break;
 | 
|  |    178 |                     }
 | 
|  |    179 |                 }
 | 
|  |    180 |             break;
 | 
|  |    181 |             }
 | 
|  |    182 |         }
 | 
|  |    183 |     return EFalse;
 | 
|  |    184 |     }
 | 
|  |    185 | 
 | 
|  |    186 | // ---------------------------------------------------------
 | 
|  |    187 | // CBrCtlApiTestObserver::HandleBrowserLoadEventL
 | 
|  |    188 | // ---------------------------------------------------------
 | 
|  |    189 | //
 | 
|  |    190 | void CBrCtlApiTestObserver::HandleBrowserLoadEventL( TBrCtlDefs::TBrCtlLoadEvent /* aLoadEvent */,
 | 
|  |    191 |                                                  TUint /* aSize */, TUint16 /* aTransactionId */ ) 
 | 
|  |    192 |     {
 | 
|  |    193 |     }
 | 
|  |    194 | 
 | 
|  |    195 | // ---------------------------------------------------------
 | 
|  |    196 | // CBrCtlApiTestObserver::ResolveEmbeddedLinkL
 | 
|  |    197 | // ---------------------------------------------------------
 | 
|  |    198 | //
 | 
|  |    199 | TBool CBrCtlApiTestObserver::ResolveEmbeddedLinkL(const TDesC& aEmbeddedUrl,
 | 
|  |    200 |     		                       const TDesC& /* aCurrentUrl */,
 | 
|  |    201 |         	                       TBrCtlLoadContentType /* aLoadContentType */, 
 | 
|  |    202 |                                    MBrCtlLinkContent& aEmbeddedLinkContent) 
 | 
|  |    203 |     {
 | 
|  |    204 |     if (IsFileScheme(aEmbeddedUrl))
 | 
|  |    205 |         {
 | 
|  |    206 |         GetFileNameL(aEmbeddedUrl);
 | 
|  |    207 |         HBufC8* buf = ReadFileLC(*iFileName);
 | 
|  |    208 |         HBufC* contentType = NULL;
 | 
|  |    209 |         TPtrC p(NULL, 0);
 | 
|  |    210 |         contentType = RecognizeLC(*iFileName, *buf);
 | 
|  |    211 |         aEmbeddedLinkContent.HandleResolveComplete(*contentType, p, buf);        
 | 
|  |    212 |         CleanupStack::PopAndDestroy(2); // contentType, buf
 | 
|  |    213 |         return ETrue;
 | 
|  |    214 |         }
 | 
|  |    215 |     return EFalse;
 | 
|  |    216 |     }
 | 
|  |    217 | 
 | 
|  |    218 | // ---------------------------------------------------------
 | 
|  |    219 | // CBrCtlApiTestObserver::ResolveLinkL
 | 
|  |    220 | // ---------------------------------------------------------
 | 
|  |    221 | //
 | 
|  |    222 | TBool CBrCtlApiTestObserver::ResolveLinkL(const TDesC& aUrl, const TDesC& /* aCurrentUrl */,
 | 
|  |    223 |                    MBrCtlLinkContent& aBrCtlLinkContent) 
 | 
|  |    224 |     {
 | 
|  |    225 |     if (IsFileScheme(aUrl))
 | 
|  |    226 |         {
 | 
|  |    227 |         GetFileNameL(aUrl);
 | 
|  |    228 |         HBufC8* buf = ReadFileLC(*iFileName);
 | 
|  |    229 |         HBufC* contentType = NULL;
 | 
|  |    230 |         TPtrC p(NULL, 0);
 | 
|  |    231 |         contentType = RecognizeLC(*iFileName, *buf);
 | 
|  |    232 |         aBrCtlLinkContent.HandleResolveComplete(*contentType, p, buf);        
 | 
|  |    233 |         CleanupStack::PopAndDestroy(2); // contentType, buf
 | 
|  |    234 |         return ETrue;
 | 
|  |    235 |         }
 | 
|  |    236 |     return EFalse;
 | 
|  |    237 |     }
 | 
|  |    238 | 
 | 
|  |    239 | 
 | 
|  |    240 | // ---------------------------------------------------------
 | 
|  |    241 | // CBrCtlApiTestObserver::CancelAll
 | 
|  |    242 | // ---------------------------------------------------------
 | 
|  |    243 | //
 | 
|  |    244 | void CBrCtlApiTestObserver::CancelAll() 
 | 
|  |    245 |     {
 | 
|  |    246 |     }
 | 
|  |    247 | 
 | 
|  |    248 | 
 | 
|  |    249 | // ---------------------------------------------------------
 | 
|  |    250 | // CBrCtlApiTestObserver::ConstructL
 | 
|  |    251 | // ---------------------------------------------------------
 | 
|  |    252 | //
 | 
|  |    253 | void CBrCtlApiTestObserver::ConstructL()
 | 
|  |    254 |     {
 | 
|  |    255 |     iHandler = CDocumentHandler::NewL(CEikonEnv::Static()->Process()) ;
 | 
|  |    256 |     }
 | 
|  |    257 | 
 | 
|  |    258 | // ---------------------------------------------------------
 | 
|  |    259 | // CBrCtlApiTestObserver::~CBrCtlApiTestObserver
 | 
|  |    260 | // ---------------------------------------------------------
 | 
|  |    261 | //
 | 
|  |    262 | CBrCtlApiTestObserver::~CBrCtlApiTestObserver()
 | 
|  |    263 |     {
 | 
|  |    264 |     delete iFileName;
 | 
|  |    265 |     delete iHandler;
 | 
|  |    266 |     }
 | 
|  |    267 | 
 | 
|  |    268 | 
 | 
|  |    269 | // ---------------------------------------------------------
 | 
|  |    270 | // CBrCtlApiTestObserver::NewL
 | 
|  |    271 | // ---------------------------------------------------------
 | 
|  |    272 | //
 | 
|  |    273 | CBrCtlApiTestObserver* CBrCtlApiTestObserver::NewL()
 | 
|  |    274 | {
 | 
|  |    275 |   CBrCtlApiTestObserver* self = new(ELeave)CBrCtlApiTestObserver;
 | 
|  |    276 |   CleanupStack::PushL(self);
 | 
|  |    277 |   self->ConstructL();
 | 
|  |    278 |   CleanupStack::Pop();
 | 
|  |    279 |   return self;
 | 
|  |    280 | }
 | 
|  |    281 | 
 | 
|  |    282 | // ---------------------------------------------------------
 | 
|  |    283 | // CBrCtlApiTestObserver::IsFileScheme
 | 
|  |    284 | // ---------------------------------------------------------
 | 
|  |    285 | //
 | 
|  |    286 | 
 | 
|  |    287 | TBool CBrCtlApiTestObserver::IsFileScheme(const TDesC& aFileName)
 | 
|  |    288 |     {
 | 
|  |    289 |     _LIT(KFileScheme, "file://");
 | 
|  |    290 |     if (aFileName.Length() > 0 && aFileName.Ptr() != NULL)
 | 
|  |    291 |         {
 | 
|  |    292 |         if (aFileName.FindF(KFileScheme) == 0)
 | 
|  |    293 |             {
 | 
|  |    294 |             return ETrue;
 | 
|  |    295 |             }
 | 
|  |    296 |         }
 | 
|  |    297 |     return EFalse;
 | 
|  |    298 |     }
 | 
|  |    299 | 
 | 
|  |    300 | // ---------------------------------------------------------
 | 
|  |    301 | // CBrCtlApiTestObserver::ReadFile
 | 
|  |    302 | // ---------------------------------------------------------
 | 
|  |    303 | //
 | 
|  |    304 | HBufC8* CBrCtlApiTestObserver::ReadFileLC(const TDesC& aFileName)
 | 
|  |    305 |     {
 | 
|  |    306 |     RFs rfs;
 | 
|  |    307 |     RFile file;
 | 
|  |    308 |     User::LeaveIfError(rfs.Connect());
 | 
|  |    309 |     CleanupClosePushL(rfs);
 | 
|  |    310 |     User::LeaveIfError(file.Open(rfs, aFileName, EFileRead));
 | 
|  |    311 |     CleanupClosePushL(file);
 | 
|  |    312 |     TInt size;
 | 
|  |    313 |     User::LeaveIfError(file.Size(size));
 | 
|  |    314 |     HBufC8* buf = HBufC8::NewLC(size);
 | 
|  |    315 |     TPtr8 bufPtr(buf->Des());
 | 
|  |    316 |     User::LeaveIfError(file.Read(bufPtr));
 | 
|  |    317 |     CleanupStack::Pop(); // buf
 | 
|  |    318 |     CleanupStack::PopAndDestroy(2); // file, rfs
 | 
|  |    319 |     CleanupStack::PushL(buf);
 | 
|  |    320 |     return buf;
 | 
|  |    321 |     }
 | 
|  |    322 | 
 | 
|  |    323 | // ---------------------------------------------------------
 | 
|  |    324 | // CBrCtlApiTestObserver::RecognizeL
 | 
|  |    325 | // ---------------------------------------------------------
 | 
|  |    326 | //
 | 
|  |    327 | HBufC* CBrCtlApiTestObserver::RecognizeLC(const TDesC& aFileName, const TDesC8& aData)
 | 
|  |    328 |     {
 | 
|  |    329 |     TDataRecognitionResult dataType;
 | 
|  |    330 |     RApaLsSession apaSession;
 | 
|  |    331 |     TInt ret;
 | 
|  |    332 |     HBufC* contentTypeString = NULL;
 | 
|  |    333 | 
 | 
|  |    334 |     User::LeaveIfError(apaSession.Connect());
 | 
|  |    335 |     // Ask the application architecture to find the file type
 | 
|  |    336 |     ret = apaSession.RecognizeData(aFileName, aData, dataType);
 | 
|  |    337 |     apaSession.Close();
 | 
|  |    338 | 
 | 
|  |    339 |     if (ret == KErrNone &&
 | 
|  |    340 |         (dataType.iConfidence == CApaDataRecognizerType::ECertain) ||
 | 
|  |    341 |         (dataType.iConfidence == CApaDataRecognizerType::EProbable))
 | 
|  |    342 |         {
 | 
|  |    343 |         // If the file type was found, try to match it to a known file type
 | 
|  |    344 |         TPtrC8 mimeTypePtr = dataType.iDataType.Des8();
 | 
|  |    345 |         TInt len = mimeTypePtr.Length() + 1;
 | 
|  |    346 |         contentTypeString = HBufC::NewL(len); 
 | 
|  |    347 |         contentTypeString->Des().Copy(mimeTypePtr);
 | 
|  |    348 |         contentTypeString->Des().ZeroTerminate();
 | 
|  |    349 |         }
 | 
|  |    350 |     CleanupStack::PushL(contentTypeString);
 | 
|  |    351 |     return contentTypeString;
 | 
|  |    352 |     }
 | 
|  |    353 | 
 | 
|  |    354 | // -----------------------------------------------------------------------------
 | 
|  |    355 | // CBrCtlApiTestObserver::GetFileNameL
 | 
|  |    356 | // Translate the file name from a URL to a valid file name in the system.
 | 
|  |    357 | // -----------------------------------------------------------------------------
 | 
|  |    358 | //
 | 
|  |    359 | TBool CBrCtlApiTestObserver::GetFileNameL(const TDesC& aFileName)
 | 
|  |    360 |     {
 | 
|  |    361 |     // This function accepts URLs in the following format:
 | 
|  |    362 |     // file://filename.xxx
 | 
|  |    363 |     // file:///filename.xxx
 | 
|  |    364 |     // file://c:/filename.xxx
 | 
|  |    365 |     // file:///c:/filename.xxx
 | 
|  |    366 |     //
 | 
|  |    367 |     _LIT(KFileScheme, "file://");
 | 
|  |    368 |     _LIT(KDefaultDrivePath, "C:\\");
 | 
|  |    369 |     _LIT(KPathChar, "\\");
 | 
|  |    370 |     
 | 
|  |    371 |     TInt count;
 | 
|  |    372 |     TInt index = 0;
 | 
|  |    373 |     TBool drvLetter = EFalse;
 | 
|  |    374 |     TUint16 c;
 | 
|  |    375 |     
 | 
|  |    376 |     // Verify the file scheme
 | 
|  |    377 |     TPtrC urlPtr(aFileName);
 | 
|  |    378 |     if (urlPtr.FindF(KFileScheme) != 0)
 | 
|  |    379 |         {
 | 
|  |    380 |         return EFalse;
 | 
|  |    381 |         }
 | 
|  |    382 |     urlPtr.Set(urlPtr.Mid(KFileScheme().Length()));
 | 
|  |    383 |     
 | 
|  |    384 |     // make sure there are enough characters in the filename before
 | 
|  |    385 |     // trying to check them
 | 
|  |    386 |     count = urlPtr.Length();
 | 
|  |    387 |     if(count == 0)
 | 
|  |    388 |         {
 | 
|  |    389 |         return EFalse;            // no filename, so can't look at urlPtr[0]
 | 
|  |    390 |         }
 | 
|  |    391 |     
 | 
|  |    392 |     // Skip the first '/' if there is one
 | 
|  |    393 |     if (urlPtr[0] == '/')
 | 
|  |    394 |         {
 | 
|  |    395 |         urlPtr.Set(urlPtr.Mid(1));
 | 
|  |    396 |         }
 | 
|  |    397 |     count = urlPtr.Length();
 | 
|  |    398 |     
 | 
|  |    399 |     // Is there a drive letter?
 | 
|  |    400 |     if(count > 1)
 | 
|  |    401 |         {
 | 
|  |    402 |         // can check for drive letter
 | 
|  |    403 |         if (urlPtr[1 + index] == ':')
 | 
|  |    404 |             {
 | 
|  |    405 |             drvLetter = ETrue;
 | 
|  |    406 |             }
 | 
|  |    407 |         }
 | 
|  |    408 |     if(drvLetter == EFalse)
 | 
|  |    409 |         {
 | 
|  |    410 |         // 3 additional characters for the string "c:\"
 | 
|  |    411 |         count = urlPtr.Length() + 3;
 | 
|  |    412 |         }
 | 
|  |    413 |     iFileName = HBufC::NewL(count);
 | 
|  |    414 |     if (!drvLetter)
 | 
|  |    415 |         {
 | 
|  |    416 |         iFileName->Des().Append(KDefaultDrivePath);
 | 
|  |    417 |         }
 | 
|  |    418 |     
 | 
|  |    419 |     TBool fragment(EFalse);
 | 
|  |    420 |     // Convert relative path containing /./ and /../ to absolute path
 | 
|  |    421 |     for (; index < urlPtr.Length() && !fragment; index ++)
 | 
|  |    422 |         {
 | 
|  |    423 |         switch(urlPtr[index])
 | 
|  |    424 |             {
 | 
|  |    425 |             case '#':    //Check if there is a fragment '#'
 | 
|  |    426 |                 {
 | 
|  |    427 |                 fragment = ETrue;
 | 
|  |    428 |                 continue; // Just stop there
 | 
|  |    429 |                 }
 | 
|  |    430 |                 
 | 
|  |    431 |             case '/':
 | 
|  |    432 |                 {
 | 
|  |    433 |                 iFileName->Des().Append(KPathChar);
 | 
|  |    434 |                 break;
 | 
|  |    435 |                 }
 | 
|  |    436 |             case '.':
 | 
|  |    437 |                 {
 | 
|  |    438 |                 if (index > 1 && urlPtr[index - 1] == '/')
 | 
|  |    439 |                     {
 | 
|  |    440 |                     if (index < count - 1 && urlPtr[index + 1] == '/')
 | 
|  |    441 |                         {
 | 
|  |    442 |                         index ++; // skip  ./
 | 
|  |    443 |                         break;
 | 
|  |    444 |                         }
 | 
|  |    445 |                     if (index > 2 && index < count - 3 &&
 | 
|  |    446 |                         urlPtr[index + 1] == '.' && urlPtr[index + 2] == '/')
 | 
|  |    447 |                         {
 | 
|  |    448 |                         TInt i = index - 2;
 | 
|  |    449 |                         
 | 
|  |    450 |                         for (; i > 0 && urlPtr[i] != '/'; i--) {} // skip  /../
 | 
|  |    451 |                         
 | 
|  |    452 |                         iFileName->Des().SetLength(iFileName->Des().Length() - (index - i));
 | 
|  |    453 |                         index += 2;
 | 
|  |    454 |                         break;
 | 
|  |    455 |                         }
 | 
|  |    456 |                     }
 | 
|  |    457 |                 }
 | 
|  |    458 |                 // no break
 | 
|  |    459 |                 //lint -fallthrough
 | 
|  |    460 |                 
 | 
|  |    461 |             default:
 | 
|  |    462 |                 {
 | 
|  |    463 |                 c = urlPtr[index];
 | 
|  |    464 |                 iFileName->Des().Append(&c, 1);
 | 
|  |    465 |                 break;
 | 
|  |    466 |                 }
 | 
|  |    467 |             }	// end of switch
 | 
|  |    468 |         }
 | 
|  |    469 |     return ETrue;
 | 
|  |    470 | }
 | 
|  |    471 | 
 | 
|  |    472 | // ---------------------------------------------------------
 | 
|  |    473 | // CBrCtlApiTestObserver::NewDownloadL
 | 
|  |    474 | // ---------------------------------------------------------
 | 
|  |    475 | //
 | 
|  |    476 | TBool CBrCtlApiTestObserver::NewDownloadL(TUint /* aTransactionID */,
 | 
|  |    477 | 									   const TDesC& /* aFileName */,
 | 
|  |    478 | 									   const TDesC& /* aContentType */,
 | 
|  |    479 | 									   const TDesC& /* aUrl */)
 | 
|  |    480 | {
 | 
|  |    481 | 	return ETrue;
 | 
|  |    482 | }
 | 
|  |    483 | 
 | 
|  |    484 | void CBrCtlApiTestObserver::ResumeDownloadL(TUint /* aTransactionID */,
 | 
|  |    485 |                                          TUint /* aLength */,
 | 
|  |    486 | 									   const TDesC& /* aFileName */,
 | 
|  |    487 | 									   const TDesC& /* aContentType */,
 | 
|  |    488 | 									   const TDesC& /* aUrl */)
 | 
|  |    489 | {
 | 
|  |    490 | }
 | 
|  |    491 | 
 | 
|  |    492 | void CBrCtlApiTestObserver::HandleDownloadEventL( TUint /* aTransactionID */, 
 | 
|  |    493 | 											  TBrCtlDownloadEvent /* aDownloadEvent */,
 | 
|  |    494 | 											  TUint /* aValue*/ )
 | 
|  |    495 | {
 | 
|  |    496 | }
 | 
|  |    497 | 
 | 
|  |    498 | // Dummy function definitions for the functions from CBrCtlWindowObserver class - Added for Widget Extension Test
 | 
|  |    499 | 
 | 
|  |    500 | // ---------------------------------------------------------
 | 
|  |    501 | // CBrCtlApiTestObserver::OpenWindowL
 | 
|  |    502 | // ---------------------------------------------------------
 | 
|  |    503 | //
 | 
|  |    504 | CBrCtlInterface* CBrCtlApiTestObserver::OpenWindowL(TDesC& aUrl, TDesC* aTargetName, TBool aUserInitiated, 
 | 
|  |    505 |      TAny* aReserved)
 | 
|  |    506 | {
 | 
|  |    507 | 	
 | 
|  |    508 | }
 | 
|  |    509 | 
 | 
|  |    510 | // ---------------------------------------------------------
 | 
|  |    511 | // CBrCtlApiTestObserver::FindWindowL
 | 
|  |    512 | // ---------------------------------------------------------
 | 
|  |    513 | //
 | 
|  |    514 | CBrCtlInterface* CBrCtlApiTestObserver::FindWindowL( const TDesC& aTargetName ) const
 | 
|  |    515 | {
 | 
|  |    516 | 	
 | 
|  |    517 | }            
 | 
|  |    518 | 
 | 
|  |    519 | // ---------------------------------------------------------
 | 
|  |    520 | // CBrCtlApiTestObserver::HandleWindowCommandL
 | 
|  |    521 | // ---------------------------------------------------------
 | 
|  |    522 | //
 | 
|  |    523 | void CBrCtlApiTestObserver::HandleWindowCommandL( const TDesC& aTargetName, TBrCtlWindowCommand aCommand )
 | 
|  |    524 | {
 | 
|  |    525 | 	
 | 
|  |    526 | }
 | 
|  |    527 | 
 | 
|  |    528 | 
 | 
|  |    529 | 
 | 
|  |    530 | // End of File  
 |