landmarks/locationlandmarks/tsrc/LandmarkTestModule/src/FT_CPosTp156.cpp
changeset 33 834e27cad510
child 35 1a92308afc46
child 40 16118e24b93b
equal deleted inserted replaced
32:b12ea03c50a3 33:834e27cad510
       
     1 /*
       
     2 * Copyright (c) 2005 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 "Symbian Foundation License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description: 
       
    15 *   ?description_line
       
    16 *
       
    17 */
       
    18 
       
    19 //  INCLUDES
       
    20 #include "FT_CPosTp156.h"
       
    21 #include <EPos_CPosLandmarkDatabase.h>
       
    22 #include <EPos_CPosLandmarkParser.h>
       
    23 #include <EPos_CPosLandmarkEncoder.h>
       
    24 #include <LbsPosition.h>
       
    25 #include <e32math.h>
       
    26 #include <bautils.h>
       
    27 #include <utf.h>
       
    28 #include <xml/xmlparsererrors.h>
       
    29 
       
    30 // CONSTANTS
       
    31 
       
    32 _LIT(KFileTrace, "c:\\documents\\LandmarksTP156Trace.txt");
       
    33 
       
    34 // See \epoc32\include\xml\XmlParserErrors.h for error codes
       
    35 
       
    36 
       
    37 
       
    38 
       
    39 // See \epoc32\include\xml\XmlParserErrors.h for error codes
       
    40 
       
    41 
       
    42 _LIT(KCorrectFile, "c:\\system\\test\\TestData\\CorrectFileFor_LandmarksTP156Trace.txt");
       
    43 
       
    44 _LIT(KKMZFile, "c:\\system\\test\\TestData\\Tp156KMZFile.kmz");
       
    45 
       
    46 
       
    47 // Maxmimum size for each line in trace file
       
    48 const TInt KBufSize = 5000;
       
    49 
       
    50 // ================= MEMBER FUNCTIONS =======================
       
    51 // ---------------------------------------------------------
       
    52 // CPosTp156::CloseTest
       
    53 //
       
    54 // (other items were commented in a header).
       
    55 // ---------------------------------------------------------
       
    56 //
       
    57 void CPosTp156::CloseTest()
       
    58     {
       
    59     iLog->Log(_L("CloseTest"));
       
    60 
       
    61     delete iEncoderBuffer;
       
    62     iEncoderBuffer = NULL;
       
    63 
       
    64     iLandmarks.ResetAndDestroy();
       
    65     iLandmarks.Close();
       
    66 
       
    67     delete iDatabase;
       
    68     iDatabase=NULL;
       
    69 
       
    70     delete iLandmarkEncoder;
       
    71     iLandmarkEncoder = NULL;
       
    72 
       
    73     delete iLandmarkParser;
       
    74     iLandmarkParser = NULL;
       
    75 
       
    76     delete iOperation;
       
    77     iOperation = NULL;
       
    78 
       
    79     TRAPD(err, RemoveGlobalCategoriesL());
       
    80     if (err != KErrNone && err != KErrNotFound)
       
    81         {
       
    82         HBufC* buf = HBufC::NewLC( 128 );
       
    83         TPtr buffer = buf->Des();
       
    84             
       
    85         buffer.Format(_L("RemoveGlobalCategoriesL leaved with %d"), err);
       
    86         iLog->Log( buffer );
       
    87         
       
    88         CleanupStack::PopAndDestroy( buf );
       
    89         }
       
    90 
       
    91     iLog->Log(_L("CloseTest Done"));
       
    92     }
       
    93     
       
    94 // ---------------------------------------------------------
       
    95 // CPosTp156::StartL
       
    96 //
       
    97 // (other items were commented in a header).
       
    98 // ---------------------------------------------------------
       
    99 //
       
   100 void CPosTp156::StartL()
       
   101     {
       
   102     BaflUtils::EnsurePathExistsL( iFileSession, KKMZFile );
       
   103 
       
   104     // Use same lm db as in composite search test
       
   105     iDatabase = UseCompositeLandmarksDbFileL();
       
   106     if (iDatabase->IsInitializingNeeded())
       
   107        {
       
   108        ExecuteAndDeleteLD(iDatabase->InitializeL());
       
   109        }
       
   110 
       
   111     // Delete the trace file
       
   112     DeleteFileL(KFileTrace);
       
   113 
       
   114     delete iDatabase;
       
   115     iDatabase = NULL;
       
   116 
       
   117     iDatabase = CPosLandmarkDatabase::OpenL();
       
   118     	
       
   119     	if (iDatabase->IsInitializingNeeded())
       
   120        {
       
   121        ExecuteAndDeleteLD(iDatabase->InitializeL());
       
   122        }
       
   123        
       
   124 
       
   125     // Do reset so that global categories are included
       
   126     CPosLmCategoryManager* categoryManager = CPosLmCategoryManager::NewL(*iDatabase);
       
   127     CleanupStack::PushL(categoryManager);
       
   128 
       
   129     ExecuteAndDeleteLD(categoryManager->ResetGlobalCategoriesL());
       
   130     CleanupStack::PopAndDestroy(categoryManager);
       
   131 
       
   132     HBufC8* emptyBuffer=NULL;
       
   133     
       
   134    	iLog->Log(_L("Test with Tp156KMZFile.kmz"));
       
   135 	PrintParsedDataFromEncoderL(KKMZFile, *emptyBuffer, -993, KKmzMimeType );
       
   136 
       
   137 
       
   138     // Now compare tha trace file against the correct one
       
   139     RFile correctFile;
       
   140     RFile file;
       
   141 
       
   142     iLog->Log(_L(">>>>>>>Comparing files<<<<<"));
       
   143     
       
   144     TFileName filename;
       
   145     CreateCorrectXmlFileL( KCorrectFile, filename );
       
   146     
       
   147     User::LeaveIfError(correctFile.Open(iFileSession, filename,  EFileRead));
       
   148     CleanupClosePushL(correctFile);
       
   149     User::LeaveIfError(file.Open(iFileSession, KFileTrace,  EFileRead));
       
   150     CleanupClosePushL(file);
       
   151 
       
   152     HBufC* correctLinebuffer = HBufC::NewLC( KBufSize );
       
   153             TPtr correctLine = correctLinebuffer->Des();    
       
   154             HBufC* linebuffer = HBufC::NewLC( KBufSize );
       
   155             TPtr line = linebuffer->Des();    
       
   156    	
       
   157     TInt err = KErrNone;
       
   158     TBool done = EFalse;
       
   159     TInt lineNr = 0;
       
   160 
       
   161     while (ReadLn(correctFile, correctLine) != KErrEof && !done)
       
   162         {
       
   163         lineNr++;
       
   164         err = ReadLn(file, line);
       
   165         if ( err == KErrEof ) 
       
   166             {
       
   167             done = ETrue;    
       
   168             }
       
   169         correctLine.Trim();
       
   170         line.Trim();
       
   171         if (correctLine.Compare(line) != KErrNone)
       
   172             {
       
   173             HBufC* buf = HBufC::NewLC( 128 );
       
   174             TPtr buffer = buf->Des();
       
   175             
       
   176             buffer.Format(_L("ERROR in TraceFile on line %d: "), lineNr);
       
   177             
       
   178             iLog->Log( buffer );
       
   179             iLog->Log( correctLine );
       
   180             iLog->Log( line );
       
   181             iErrorsFound++;
       
   182             CleanupStack::PopAndDestroy( buf );
       
   183             }
       
   184         }
       
   185 		CleanupStack::PopAndDestroy(linebuffer);
       
   186     CleanupStack::PopAndDestroy(correctLinebuffer);
       
   187     CleanupStack::PopAndDestroy(&file);
       
   188     CleanupStack::PopAndDestroy(&correctFile);
       
   189 
       
   190     // EOF for trace file was reach before EOF in the correct file
       
   191     if (done)
       
   192         {
       
   193         iLog->Log(_L("ERROR: EOF for Trace file was reached to early"));
       
   194         iErrorsFound++;
       
   195         }
       
   196         
       
   197         
       
   198     DoCancelTestL();
       
   199 
       
   200     if (iErrorsFound != KErrNone)
       
   201         {
       
   202     	iLog->Log(_L("Errors found in TP156"));
       
   203     	User::Leave(-1);
       
   204         }
       
   205 	}
       
   206 
       
   207 // ---------------------------------------------------------
       
   208 // CPosTp156::DoCancelTestL
       
   209 //
       
   210 // (other items were commented in a header).
       
   211 // ---------------------------------------------------------
       
   212 //
       
   213 void CPosTp156::DoCancelTestL()
       
   214     {
       
   215     iLog->Log(_L("DoCancelTestL"));
       
   216     iLandmarkParser = CPosLandmarkParser::NewL(KKmzMimeType);
       
   217     iLandmarkParser->SetInputFileL(KKMZFile);
       
   218 
       
   219     iOperation = iLandmarkParser->ParseContentL();
       
   220 
       
   221     TRequestStatus status = KPosLmOperationNotComplete;
       
   222     TReal32 progress;
       
   223 
       
   224     // 1 ) Cancel parse function by deleting iOperation
       
   225     delete iOperation;
       
   226     iOperation = NULL;
       
   227 
       
   228     TUint32 nr = iLandmarkParser->NumOfParsedLandmarks();
       
   229     if ((TInt)nr != 0)
       
   230     {
       
   231     	iLog->Log(_L("No landmarks should be found"));
       
   232     	User::Leave(KErrNone);
       
   233     }
       
   234 
       
   235     // No landmark should be found
       
   236     TRAPD(err, iLandmarkParser->LandmarkLC());
       
   237     if (err != KErrNotFound)
       
   238         {
       
   239         iLog->Log(_L("ERROR: No Landmark should be found"));
       
   240         iErrorsFound++;
       
   241         }
       
   242 
       
   243     // 1 ) Cancel parse function by changing input
       
   244     iOperation = iLandmarkParser->ParseContentL();
       
   245 
       
   246     // Get the first landmark
       
   247     iOperation->NextStep(status, progress);
       
   248     // Wait for NextStep to complete
       
   249     User::WaitForRequest(status);
       
   250     if(status == KErrNone)
       
   251 	{
       
   252 	   	nr = iLandmarkParser->NumOfParsedLandmarks();
       
   253 	    if ((TInt)nr != 1)
       
   254 	    {
       
   255 	    	iLog->Log(_L("One landmark should be found"));
       
   256 	    	iErrorsFound++;
       
   257 	    }
       
   258     }
       
   259 
       
   260     // Change input
       
   261     iLandmarkParser->SetInputFileL(KKMZFile);
       
   262 
       
   263     nr = iLandmarkParser->NumOfParsedLandmarks();
       
   264     if ((TInt)nr != 0)
       
   265     {
       
   266     	iLog->Log(_L("No landmarks should be found"));
       
   267     	User::Leave(KErrNone);
       
   268     }
       
   269 
       
   270     // No landmark should be found
       
   271     TRAP(err, iLandmarkParser->LandmarkLC());
       
   272     if (err != KErrNotFound)
       
   273         {
       
   274         iLog->Log(_L("ERROR: No Landmark should be found"));
       
   275         iErrorsFound++;
       
   276         }
       
   277 
       
   278     delete iOperation;
       
   279     iOperation = NULL;
       
   280     delete iLandmarkParser;
       
   281     iLandmarkParser = NULL;
       
   282     iLog->Log(_L("DoCancelTestL Done"));
       
   283     }
       
   284     
       
   285  // ---------------------------------------------------------
       
   286 // CPosTp156::PrintParsedDataFromEncoderL
       
   287 //
       
   288 // (other items were commented in a header).
       
   289 // ---------------------------------------------------------
       
   290 //
       
   291 void CPosTp156::PrintParsedDataFromEncoderL(
       
   292     const TDesC& aFile, 
       
   293     const TDesC8&  aBuffer, 
       
   294     TInt aExpectedStatusCode,
       
   295     const TDesC8& aMimeType)
       
   296     {
       
   297     iLog->Log(_L("===== PrintParsedDataFromEncoderL ======="));
       
   298     
       
   299     iLandmarkParser = CPosLandmarkParser::NewL(aMimeType);
       
   300 
       
   301     if (aFile != KNullDesC)
       
   302         {
       
   303         TFileName file( aFile );
       
   304         iLog->Log(_L("FILE (%S)"), &file );
       
   305         TraceL(_L("----->Using FILE<-------"));
       
   306         TraceL(file);
       
   307         iLandmarkParser->SetInputFileL(file);
       
   308         }
       
   309     else
       
   310         {
       
   311         iLog->Log(_L("BUFFER (size %d)"), aBuffer.Size() );
       
   312         TraceL(_L("----->Using BUFFER<-------"));
       
   313         iLandmarkParser->SetInputBuffer(aBuffer);
       
   314         }
       
   315 
       
   316     iOperation = iLandmarkParser->ParseContentL();
       
   317     TRequestStatus status = KPosLmOperationNotComplete;
       
   318     TReal32 progress;
       
   319     TInt number = 0;
       
   320 
       
   321     RArray<TPosLmItemId> array;
       
   322     CleanupClosePushL(array);
       
   323 
       
   324     while (status == KPosLmOperationNotComplete)
       
   325         {
       
   326         iLog->Log(_L("--- Parsing ---------------------------"));
       
   327         TraceL(_L("------------------------------"));
       
   328         iOperation->NextStep(status, progress);
       
   329 
       
   330         // Wait for NextStep to complete
       
   331         User::WaitForRequest(status);
       
   332         if (status != KPosLmOperationNotComplete && status != KErrNone)
       
   333             {
       
   334             iLog->Log(_L("Parsing Complete"));
       
   335             
       
   336             HBufC* buffer = HBufC::NewLC( 128);
       
   337             TPtr buf = buffer->Des();
       
   338                        
       
   339             buf.Format(_L("\tStatus %d"), status.Int());
       
   340             iLog->Log(buf);
       
   341             TraceL(buf);
       
   342             
       
   343             CleanupStack::PopAndDestroy( buffer );
       
   344             buffer = NULL;              
       
   345             }
       
   346         else
       
   347             {
       
   348             iLog->Log(_L("Parsing element"));
       
   349             if ( iLandmarkParser->NumOfParsedLandmarks() )
       
   350                 {
       
   351                 // Get last parsed landmark
       
   352                 CPosLandmark* lm = iLandmarkParser->LandmarkLC();
       
   353                 TPtrC lmName;
       
   354                 TPtrC catName;
       
   355                 lm->GetLandmarkName(lmName);
       
   356                 lm->GetCategoriesL(array);
       
   357                 //iLog->Log(lmName);
       
   358                 for (TInt i=0;i<array.Count();i++)
       
   359                     {
       
   360                     CPosLandmarkCategory* category = iLandmarkParser->LandmarkCategoryLC(array[i]);
       
   361                     category->GetCategoryName( catName );
       
   362                      
       
   363                     HBufC* buffer = HBufC::NewLC( 128 + catName.Length());
       
   364                     TPtr buf = buffer->Des();
       
   365                                             
       
   366                     if ( category->GlobalCategory()) 
       
   367                         {
       
   368                         buf.Append(_L("\tGlobal category: "));    
       
   369                         }
       
   370                     else 
       
   371                         {
       
   372                         buf.Append(_L("\tLocal category: "));    
       
   373                         }                        
       
   374                                         
       
   375                     buf.Append( catName );
       
   376                     iLog->Log( buf );
       
   377                     TraceL( buf );
       
   378 
       
   379                     CleanupStack::PopAndDestroy( buffer );
       
   380                     buffer = NULL;
       
   381                     CleanupStack::PopAndDestroy(category);
       
   382                     }
       
   383                     
       
   384                	PrintLandmarkFieldsWithDescriptionL(*lm, ETrue);	
       
   385                
       
   386                 
       
   387                 number++;
       
   388                 CleanupStack::PopAndDestroy(lm);
       
   389                 }
       
   390             }
       
   391         }
       
   392 
       
   393     iLog->Log(_L("--- Parsing end ---------------------------"));
       
   394     TraceL(_L("------------------------------"));
       
   395     CleanupStack::PopAndDestroy(&array);
       
   396 
       
   397     if (status.Int() != aExpectedStatusCode)
       
   398         {
       
   399         HBufC* buffer = HBufC::NewLC( 128 );
       
   400         TPtr buf = buffer->Des();
       
   401                     
       
   402         buf.Format(_L("\tERROR: Wrong status returned, was %d, should be %d"), status.Int(), aExpectedStatusCode);
       
   403         iLog->Log( buf );
       
   404         iErrorsFound++;
       
   405         
       
   406         CleanupStack::PopAndDestroy( buffer );
       
   407         buffer = NULL;        
       
   408         }
       
   409 
       
   410     TUint32 nr = iLandmarkParser->NumOfParsedLandmarks();
       
   411     HBufC* buffer = HBufC::NewLC( 256 );
       
   412     TPtr buf = buffer->Des();
       
   413     buf.Format(_L("\tNr of Parsed landmarks %d, should be %d"), nr, number);
       
   414     iLog->Log(buf);
       
   415     TraceL(buf);
       
   416 
       
   417     CleanupStack::PopAndDestroy( buffer );
       
   418     buffer = NULL;
       
   419     if (nr != (TUint32)number)
       
   420         {
       
   421         iLog->Log(_L("\tERROR: Wrong number of landmarks parsed returned!"));
       
   422         iErrorsFound++;
       
   423         }
       
   424 
       
   425     TPosLmCollectionDataId lmId = iLandmarkParser->FirstCollectionDataId();
       
   426 
       
   427     iLog->Log(_L("--- CollectionData ---"));
       
   428     TraceL(_L("--- CollectionData ---"));
       
   429 
       
   430     if (lmId != EPosLmCollDataNone)
       
   431         {
       
   432         TPtrC first = iLandmarkParser->CollectionData(lmId);
       
   433         HBufC* buffer = HBufC::NewLC( first.Length() + 256 );
       
   434         TPtr buf = buffer->Des();
       
   435         buf.Zero();
       
   436         buf.Format(_L("\t(1)Collection Id: %d CollectionData: "), lmId);
       
   437         buf.Append(first);
       
   438         iLog->Log(buf);
       
   439         TraceL(buf);
       
   440         CleanupStack::PopAndDestroy( buffer );
       
   441         buffer = NULL;      
       
   442         }
       
   443     else 
       
   444         {
       
   445         iLog->Log(_L("\tNo collection data found 1"));    
       
   446         }
       
   447 
       
   448     while (lmId != EPosLmCollDataNone)
       
   449         {
       
   450         lmId = iLandmarkParser->NextCollectionDataId(lmId);
       
   451         if (lmId != EPosLmCollDataNone)
       
   452         {
       
   453             TPtrC first = iLandmarkParser->CollectionData(lmId);
       
   454             
       
   455             HBufC* buffer = HBufC::NewLC( first.Length() + 256 );
       
   456             TPtr buf = buffer->Des();         
       
   457             buf.Zero();
       
   458             buf.Format(_L("\t(2)Collection Id: %d CollectionData: "), lmId);
       
   459             buf.Append(first);
       
   460             iLog->Log(buf);
       
   461             TraceL(buf);
       
   462             
       
   463             CleanupStack::PopAndDestroy( buffer );
       
   464             buffer = NULL;              
       
   465             }
       
   466         else 
       
   467             {
       
   468             iLog->Log(_L("\tNo collection data found 2"));   
       
   469             }
       
   470         }
       
   471 
       
   472     iLog->Log(_L("--- CollectionData ---"));
       
   473     TraceL(_L("--- CollectionData ---"));
       
   474 
       
   475     delete iOperation;
       
   476     iOperation = NULL;
       
   477     delete iLandmarkParser;
       
   478     iLandmarkParser = NULL;
       
   479     iLog->Log(_L("====== PrintParsedDataFromEncoderL Done ========\n"));
       
   480     }
       
   481     
       
   482     
       
   483  // ---------------------------------------------------------
       
   484 // CPosTp156::PrintLandmarkFieldsWithDescriptionL
       
   485 //
       
   486 // (other items were commented in a header).
       
   487 // ---------------------------------------------------------
       
   488 //
       
   489 void CPosTp156::PrintLandmarkFieldsWithDescriptionL(const CPosLandmark& aLandmark, TBool aTraceFlag)
       
   490     {
       
   491     iLog->Log(_L("Parsing Description ... \n"));
       
   492     TPositionFieldId sourceFieldId = aLandmark.FirstPositionFieldId();
       
   493     TLocality loc;
       
   494     
       
   495 
       
   496     TInt err;
       
   497     TPtrC landmarkName;
       
   498     TPtrC landmarkDescription;
       
   499     err = aLandmark.GetLandmarkName(landmarkName);
       
   500     if (err == KErrNone)
       
   501         {
       
   502         HBufC* buffer = HBufC::NewLC( landmarkName.Length() + 256 );
       
   503         TPtr buf = buffer->Des();
       
   504         buf.Append(_L("\tLandmark Name: "));
       
   505         buf.Append(landmarkName);
       
   506         iLog->Log(buf);
       
   507         if( aTraceFlag ) 
       
   508             {
       
   509             TraceL( buf );   
       
   510             }
       
   511             
       
   512         CleanupStack::PopAndDestroy( buffer );
       
   513         buffer = NULL;  
       
   514         }
       
   515 
       
   516     err = aLandmark.GetPosition(loc);
       
   517     if (err == KErrNone)
       
   518         {
       
   519         HBufC* buffer = HBufC::NewLC( 1024 );
       
   520         TPtr buf = buffer->Des();        
       
   521         TRealFormat format( 12, KRealFormatFixed );
       
   522         format.iPoint = TChar('.');
       
   523         format.iTriLen = KDoNotUseTriads;
       
   524         format.iPlaces = 6;
       
   525         
       
   526         TBuf<20> sLon, sLat, sVacc, sHacc, sAlt, sRad;
       
   527         sLon.Num( loc.Longitude(), format );
       
   528         sLat.Num( loc.Latitude(), format );
       
   529         sAlt.Num( loc.Altitude(), format );
       
   530         sVacc.Num( loc.VerticalAccuracy(), format );
       
   531         sHacc.Num( loc.HorizontalAccuracy(), format );
       
   532         buf.Format(
       
   533             _L("\tLM: Long %S Lat %S vertAcc %S horAcc %S alt %S "), 
       
   534             &sLon, &sLat, &sVacc, &sHacc, &sAlt);
       
   535         
       
   536         TReal32 sourceR;
       
   537         err = aLandmark.GetCoverageRadius(sourceR);
       
   538         if (err == KErrNone )
       
   539             {
       
   540             sRad.Num( sourceR, format );
       
   541             buf.AppendFormat(_L("srcRadius %S"), &sRad);
       
   542             }
       
   543         iLog->Log(buf);
       
   544         if (aTraceFlag) TraceL(buf);
       
   545         CleanupStack::PopAndDestroy( buffer );
       
   546         buffer = NULL;  
       
   547         }
       
   548         
       
   549       //Get landmark description  
       
   550       err = aLandmark.GetLandmarkDescription(landmarkDescription);
       
   551       if (err == KErrNone)
       
   552         {
       
   553         HBufC* buffer = HBufC::NewLC( landmarkDescription.Length() + 256 );
       
   554         TPtr buf = buffer->Des();         
       
   555         buf.Format(_L("\tLandmark Description: "));
       
   556         buf.Append(landmarkDescription);
       
   557         iLog->Log(buf);
       
   558         if ( aTraceFlag ) 
       
   559             {
       
   560             TraceL( buf );    
       
   561             }
       
   562         
       
   563         CleanupStack::PopAndDestroy( buffer );
       
   564         buffer = NULL;         
       
   565         }  
       
   566     
       
   567 
       
   568     while (sourceFieldId != EPositionFieldNone)
       
   569         {
       
   570         TPtrC sourceValue;
       
   571         aLandmark.GetPositionField(sourceFieldId, sourceValue);
       
   572         HBufC* buffer = HBufC::NewLC( sourceValue.Length() + 256 );
       
   573         TPtr buf = buffer->Des();  
       
   574         buf.Format(_L("\tIdField Id: %d Value:"), sourceFieldId);
       
   575         buf.Append(sourceValue);
       
   576         iLog->Log(buf);
       
   577         if ( aTraceFlag ) 
       
   578             {
       
   579             TraceL( buf );
       
   580             }
       
   581         sourceFieldId = aLandmark.NextPositionFieldId(sourceFieldId);
       
   582         
       
   583         CleanupStack::PopAndDestroy( buffer );
       
   584         }
       
   585     }
       
   586     
       
   587     
       
   588 // ---------------------------------------------------------
       
   589 // CPosTp156::TraceL
       
   590 //
       
   591 // (other items were commented in a header).
       
   592 // ---------------------------------------------------------
       
   593 //
       
   594 void CPosTp156::TraceL(const TDesC& msg)
       
   595     {
       
   596     _LIT8( KEnd, "\r\n" );
       
   597 
       
   598     RFile file;
       
   599     TInt err = file.Open(iFileSession, KFileTrace, EFileWrite);
       
   600     if (err == KErrNotFound)
       
   601         {
       
   602         file.Create(iFileSession, KFileTrace, EFileWrite);
       
   603         }
       
   604 
       
   605     HBufC8* line8 = CnvUtfConverter::ConvertFromUnicodeToUtf8L( msg );
       
   606     
       
   607     TInt pos( 0 );
       
   608     file.Seek( ESeekEnd, pos );
       
   609     file.Write( *line8 );
       
   610     file.Write( KEnd );
       
   611     file.Close();
       
   612 
       
   613     delete line8;
       
   614     }
       
   615 
       
   616 //  End of File