landmarks/locationlandmarks/tsrc/LandmarkTestModule/src/FT_CPosTp154.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_CPosTp154.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\\LandmarksTP154Trace.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_LandmarksTP154Trace.txt");
       
    43 
       
    44 _LIT(KKMZFile, "c:\\system\\test\\TestData\\Tp154KMZFile.kmz");
       
    45 
       
    46 
       
    47 // Maxmimum size for each line in trace file
       
    48 const TInt KBufSize = 5000;
       
    49 
       
    50 // ================= MEMBER FUNCTIONS =======================
       
    51 // ---------------------------------------------------------
       
    52 // CPosTp154::CloseTest
       
    53 //
       
    54 // (other items were commented in a header).
       
    55 // ---------------------------------------------------------
       
    56 //
       
    57 void CPosTp154::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 // CPosTp154::StartL
       
    96 //
       
    97 // (other items were commented in a header).
       
    98 // ---------------------------------------------------------
       
    99 //
       
   100 void CPosTp154::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     // Do reset so that global categories are included
       
   125     CPosLmCategoryManager* categoryManager = CPosLmCategoryManager::NewL(*iDatabase);
       
   126     CleanupStack::PushL(categoryManager);
       
   127 
       
   128     ExecuteAndDeleteLD(categoryManager->ResetGlobalCategoriesL());
       
   129     CleanupStack::PopAndDestroy(categoryManager);
       
   130 
       
   131     HBufC8* emptyBuffer=NULL;
       
   132     
       
   133    	iLog->Log(_L("Test with Tp154KMZFile.kmz"));
       
   134 	PrintParsedDataFromEncoderL(KKMZFile, *emptyBuffer, -993, KKmzMimeType ); //EXmlTagMismatch = -993
       
   135 
       
   136 
       
   137     // Now compare tha trace file against the correct one
       
   138     RFile correctFile;
       
   139     RFile file;
       
   140 
       
   141     iLog->Log(_L(">>>>>>>Comparing files<<<<<"));
       
   142     
       
   143     TFileName filename;
       
   144     CreateCorrectXmlFileL( KCorrectFile, filename );
       
   145     
       
   146     User::LeaveIfError(correctFile.Open(iFileSession, filename,  EFileRead));
       
   147     CleanupClosePushL(correctFile);
       
   148     User::LeaveIfError(file.Open(iFileSession, KFileTrace,  EFileRead));
       
   149     CleanupClosePushL(file);
       
   150 
       
   151     HBufC * correctLinebuffer = HBufC::NewLC(KBufSize);
       
   152    	TPtr correctLine(correctLinebuffer->Des());
       
   153    	HBufC * linebuffer = HBufC::NewLC(KBufSize);
       
   154    	TPtr line(linebuffer->Des());
       
   155    	
       
   156     TInt err = KErrNone;
       
   157     TBool done = EFalse;
       
   158     TInt lineNr = 0;
       
   159 
       
   160     while (ReadLn(correctFile, correctLine) != KErrEof && !done)
       
   161         {
       
   162         lineNr++;
       
   163         err = ReadLn(file, line);
       
   164         if ( err == KErrEof ) 
       
   165             {
       
   166             done = ETrue;    
       
   167             }
       
   168         correctLine.Trim();
       
   169         line.Trim();
       
   170         if (correctLine.Compare(line) != KErrNone)
       
   171             {
       
   172             HBufC* buf = HBufC::NewLC( 128 );
       
   173             TPtr buffer = buf->Des();
       
   174             
       
   175             buffer.Format(_L("ERROR in TraceFile on line %d: "), lineNr);
       
   176             
       
   177             iLog->Log( buffer );
       
   178             iLog->Log( correctLine );
       
   179             iLog->Log( line );
       
   180             iErrorsFound++;
       
   181             CleanupStack::PopAndDestroy( buf );
       
   182             }
       
   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 TP154"));
       
   203     	User::Leave(-1);
       
   204         }
       
   205 	}
       
   206 
       
   207 // ---------------------------------------------------------
       
   208 // CPosTp154::DoCancelTestL
       
   209 //
       
   210 // (other items were commented in a header).
       
   211 // ---------------------------------------------------------
       
   212 //
       
   213 void CPosTp154::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     nr = iLandmarkParser->NumOfParsedLandmarks();
       
   251     if ((TInt)nr != 1)
       
   252     {
       
   253     	iLog->Log(_L("One landmark should be found"));
       
   254     	User::Leave(KErrNone);
       
   255     }
       
   256 
       
   257     // Change input
       
   258     iLandmarkParser->SetInputFileL(KKMZFile);
       
   259 
       
   260     nr = iLandmarkParser->NumOfParsedLandmarks();
       
   261     if ((TInt)nr != 0)
       
   262     {
       
   263     	iLog->Log(_L("No landmarks should be found"));
       
   264     	User::Leave(KErrNone);
       
   265     }
       
   266 
       
   267     // No landmark should be found
       
   268     TRAP(err, iLandmarkParser->LandmarkLC());
       
   269     if (err != KErrNotFound)
       
   270         {
       
   271         iLog->Log(_L("ERROR: No Landmark should be found"));
       
   272         iErrorsFound++;
       
   273         }
       
   274 
       
   275     delete iOperation;
       
   276     iOperation = NULL;
       
   277     delete iLandmarkParser;
       
   278     iLandmarkParser = NULL;
       
   279     iLog->Log(_L("DoCancelTestL Done"));
       
   280     }
       
   281     
       
   282  // ---------------------------------------------------------
       
   283 // CPosTp154::PrintParsedDataFromEncoderL
       
   284 //
       
   285 // (other items were commented in a header).
       
   286 // ---------------------------------------------------------
       
   287 //
       
   288 void CPosTp154::PrintParsedDataFromEncoderL(
       
   289     const TDesC& aFile, 
       
   290     const TDesC8&  aBuffer, 
       
   291     TInt aExpectedStatusCode,
       
   292     const TDesC8& aMimeType)
       
   293     {
       
   294     iLog->Log(_L("===== PrintParsedDataFromEncoderL ======="));
       
   295     
       
   296     iLandmarkParser = CPosLandmarkParser::NewL(aMimeType);
       
   297 
       
   298     if (aFile != KNullDesC)
       
   299         {
       
   300         TFileName file( aFile );
       
   301         iLog->Log(_L("FILE (%S)"), &file );
       
   302         TraceL(_L("----->Using FILE<-------"));
       
   303         TraceL(file);
       
   304         iLandmarkParser->SetInputFileL(file);
       
   305         }
       
   306     else
       
   307         {
       
   308         iLog->Log(_L("BUFFER (size %d)"), aBuffer.Size() );
       
   309         TraceL(_L("----->Using BUFFER<-------"));
       
   310         iLandmarkParser->SetInputBuffer(aBuffer);
       
   311         }
       
   312 
       
   313     iOperation = iLandmarkParser->ParseContentL();
       
   314     TRequestStatus status = KPosLmOperationNotComplete;
       
   315     TReal32 progress;
       
   316     TInt number = 0;
       
   317 
       
   318     RArray<TPosLmItemId> array;
       
   319     CleanupClosePushL(array);
       
   320 
       
   321     while (status == KPosLmOperationNotComplete)
       
   322         {
       
   323         iLog->Log(_L("--- Parsing ---------------------------"));
       
   324         TraceL(_L("------------------------------"));
       
   325         iOperation->NextStep(status, progress);
       
   326 
       
   327         // Wait for NextStep to complete
       
   328         User::WaitForRequest(status);
       
   329         if (status != KPosLmOperationNotComplete && status != KErrNone)
       
   330             {
       
   331             iLog->Log(_L("Parsing Complete"));
       
   332             
       
   333             HBufC* buffer = HBufC::NewLC( 128);
       
   334             TPtr buf = buffer->Des();
       
   335             buf.Format(_L("\tStatus %d"), status.Int());
       
   336             iLog->Log(buf);
       
   337             TraceL(buf);
       
   338             
       
   339             CleanupStack::PopAndDestroy( buffer );
       
   340             buffer = NULL;              
       
   341             }
       
   342         else
       
   343             {
       
   344             iLog->Log(_L("Parsing element"));
       
   345             if ( iLandmarkParser->NumOfParsedLandmarks() )
       
   346                 {
       
   347                 // Get last parsed landmark
       
   348                 CPosLandmark* lm = iLandmarkParser->LandmarkLC();
       
   349                 TPtrC lmName;
       
   350                 TPtrC catName;
       
   351                 lm->GetLandmarkName(lmName);
       
   352                 lm->GetCategoriesL(array);
       
   353                 //iLog->Log(lmName);
       
   354                 for (TInt i=0;i<array.Count();i++)
       
   355                     {
       
   356                     CPosLandmarkCategory* category = iLandmarkParser->LandmarkCategoryLC( array[i] );
       
   357                     category->GetCategoryName( catName );
       
   358                      
       
   359                     HBufC* buffer = HBufC::NewLC( 128 + catName.Length());
       
   360                     TPtr buf = buffer->Des();
       
   361                                             
       
   362                     if ( category->GlobalCategory()) 
       
   363                         {
       
   364                         buf.Append(_L("\tGlobal category: "));    
       
   365                         }
       
   366                     else 
       
   367                         {
       
   368                         buf.Append(_L("\tLocal category: "));    
       
   369                         }                        
       
   370                     buf.Append(catName);
       
   371                     iLog->Log(buf);
       
   372                     TraceL(buf);
       
   373                     CleanupStack::PopAndDestroy( buffer );
       
   374                     buffer = NULL;
       
   375                     CleanupStack::PopAndDestroy(category);
       
   376                     }
       
   377                     
       
   378                	PrintLandmarkFieldsWithDescriptionL(*lm, ETrue);	
       
   379                
       
   380                 
       
   381                 number++;
       
   382                 CleanupStack::PopAndDestroy(lm);
       
   383                 }
       
   384             }
       
   385         }
       
   386 
       
   387     iLog->Log(_L("--- Parsing end ---------------------------"));
       
   388     TraceL(_L("------------------------------"));
       
   389     CleanupStack::PopAndDestroy(&array);
       
   390 
       
   391     if (status.Int() != aExpectedStatusCode)
       
   392         {
       
   393         HBufC* buffer = HBufC::NewLC( 128 );
       
   394         TPtr buf = buffer->Des();
       
   395                     
       
   396         buf.Format(_L("\tERROR: Wrong status returned, was %d, should be %d"), status.Int(), aExpectedStatusCode);
       
   397         iLog->Log( buf );
       
   398         iErrorsFound++;
       
   399         
       
   400         CleanupStack::PopAndDestroy( buffer );
       
   401         buffer = NULL;        
       
   402         }
       
   403 
       
   404     TUint32 nr = iLandmarkParser->NumOfParsedLandmarks();
       
   405     HBufC* buffer = HBufC::NewLC( 256 );
       
   406     TPtr buf = buffer->Des();
       
   407     buf.Format(_L("\tNr of Parsed landmarks %d, should be %d"), nr, number);
       
   408     iLog->Log(buf);
       
   409     TraceL(buf);
       
   410 
       
   411     CleanupStack::PopAndDestroy( buffer );
       
   412     buffer = NULL;
       
   413     if (nr != (TUint32)number)
       
   414         {
       
   415         iLog->Log(_L("\tERROR: Wrong number of landmarks parsed returned!"));
       
   416         iErrorsFound++;
       
   417         }
       
   418 
       
   419     TPosLmCollectionDataId lmId = iLandmarkParser->FirstCollectionDataId();
       
   420 
       
   421     iLog->Log(_L("--- CollectionData ---"));
       
   422     TraceL(_L("--- CollectionData ---"));
       
   423 
       
   424     if (lmId != EPosLmCollDataNone)
       
   425         {
       
   426         TPtrC first = iLandmarkParser->CollectionData(lmId);
       
   427         HBufC* buffer = HBufC::NewLC( first.Length() + 256 );
       
   428         TPtr buf = buffer->Des();
       
   429         buf.Zero();
       
   430         buf.Format(_L("\t(1)Collection Id: %d CollectionData: "), lmId);
       
   431         buf.Append(first);
       
   432         iLog->Log(buf);
       
   433         TraceL(buf);
       
   434         CleanupStack::PopAndDestroy( buffer );
       
   435         buffer = NULL;      
       
   436         }
       
   437     else 
       
   438         {
       
   439         iLog->Log(_L("\tNo collection data found 1"));    
       
   440         }
       
   441 
       
   442     while (lmId != EPosLmCollDataNone)
       
   443         {
       
   444         lmId = iLandmarkParser->NextCollectionDataId(lmId);
       
   445         if (lmId != EPosLmCollDataNone)
       
   446         {
       
   447             TPtrC first = iLandmarkParser->CollectionData(lmId);
       
   448             
       
   449             HBufC* buffer = HBufC::NewLC( first.Length() + 256 );
       
   450             TPtr buf = buffer->Des();         
       
   451             buf.Zero();
       
   452             buf.Format(_L("\t(2)Collection Id: %d CollectionData: "), lmId);
       
   453             buf.Append(first);
       
   454             iLog->Log(buf);
       
   455             TraceL(buf);
       
   456             
       
   457             CleanupStack::PopAndDestroy( buffer );
       
   458             buffer = NULL;              
       
   459             }
       
   460         else 
       
   461             {
       
   462             iLog->Log(_L("\tNo collection data found 2"));   
       
   463             }
       
   464         }
       
   465 
       
   466     iLog->Log(_L("--- CollectionData ---"));
       
   467     TraceL(_L("--- CollectionData ---"));
       
   468 
       
   469     delete iOperation;
       
   470     iOperation = NULL;
       
   471     delete iLandmarkParser;
       
   472     iLandmarkParser = NULL;
       
   473     iLog->Log(_L("====== PrintParsedDataFromEncoderL Done ========\n"));
       
   474     }
       
   475     
       
   476     
       
   477  // ---------------------------------------------------------
       
   478 // CPosTp154::PrintLandmarkFieldsWithDescriptionL
       
   479 //
       
   480 // (other items were commented in a header).
       
   481 // ---------------------------------------------------------
       
   482 //
       
   483 void CPosTp154::PrintLandmarkFieldsWithDescriptionL(const CPosLandmark& aLandmark, TBool aTraceFlag)
       
   484     {
       
   485     iLog->Log(_L("Parsing Description ... \n"));
       
   486     TPositionFieldId sourceFieldId = aLandmark.FirstPositionFieldId();
       
   487     TLocality loc;
       
   488 
       
   489     TInt err;
       
   490     TPtrC landmarkName;
       
   491     TPtrC landmarkDescription;
       
   492     err = aLandmark.GetLandmarkName(landmarkName);
       
   493     if (err == KErrNone)
       
   494         {
       
   495         HBufC* buffer = HBufC::NewLC( landmarkName.Length() + 256 );
       
   496         TPtr buf = buffer->Des();
       
   497                     
       
   498         buf.Append( _L(" \tLandmark Name: "));
       
   499         buf.Append( landmarkName );
       
   500         iLog->Log( buf );
       
   501         if( aTraceFlag ) 
       
   502             {
       
   503             TraceL( buf );   
       
   504             }
       
   505             
       
   506         CleanupStack::PopAndDestroy( buffer );
       
   507         buffer = NULL;  
       
   508         }
       
   509 
       
   510     err = aLandmark.GetPosition(loc);
       
   511     if (err == KErrNone)
       
   512         {
       
   513         HBufC* buffer = HBufC::NewLC( 1024 );
       
   514         TPtr buf = buffer->Des();        
       
   515         TRealFormat format( 12, KRealFormatFixed );
       
   516         format.iPoint = TChar('.');
       
   517         format.iTriLen = KDoNotUseTriads;
       
   518         format.iPlaces = 6;
       
   519         
       
   520         TBuf<20> sLon, sLat, sVacc, sHacc, sAlt, sRad;
       
   521         sLon.Num( loc.Longitude(), format );
       
   522         sLat.Num( loc.Latitude(), format );
       
   523         sAlt.Num( loc.Altitude(), format );
       
   524         sVacc.Num( loc.VerticalAccuracy(), format );
       
   525         sHacc.Num( loc.HorizontalAccuracy(), format );
       
   526         buf.Format(
       
   527             _L("\tLM: Long %S Lat %S vertAcc %S horAcc %S alt %S "), 
       
   528             &sLon, &sLat, &sVacc, &sHacc, &sAlt);
       
   529         
       
   530         TReal32 sourceR;
       
   531         err = aLandmark.GetCoverageRadius(sourceR);
       
   532         if (err == KErrNone )
       
   533             {
       
   534             sRad.Num( sourceR, format );
       
   535             buf.AppendFormat(_L("srcRadius %S"), &sRad);
       
   536             }
       
   537         iLog->Log(buf);
       
   538         if (aTraceFlag) TraceL(buf);
       
   539         CleanupStack::PopAndDestroy( buffer );
       
   540         buffer = NULL;  
       
   541         }
       
   542         
       
   543       //Get landmark description  
       
   544       err = aLandmark.GetLandmarkDescription(landmarkDescription);
       
   545       if (err == KErrNone)
       
   546         {
       
   547         HBufC* buffer = HBufC::NewLC( landmarkDescription.Length() + 256 );
       
   548         TPtr buf = buffer->Des();         
       
   549         buf.Format(_L("\tLandmark Description: "));
       
   550         buf.Append(landmarkDescription);
       
   551         iLog->Log(buf);
       
   552         if ( aTraceFlag ) 
       
   553             {
       
   554             TraceL( buf );    
       
   555             }
       
   556         
       
   557         CleanupStack::PopAndDestroy( buffer );
       
   558         buffer = NULL;         
       
   559         }  
       
   560     
       
   561 
       
   562     while (sourceFieldId != EPositionFieldNone)
       
   563         {
       
   564         TPtrC sourceValue;
       
   565         aLandmark.GetPositionField(sourceFieldId, sourceValue);
       
   566         HBufC* buffer = HBufC::NewLC( sourceValue.Length() + 256 );
       
   567         TPtr buf = buffer->Des();  
       
   568         buf.Format(_L("\tIdField Id: %d Value:"), sourceFieldId);
       
   569         buf.Append(sourceValue);
       
   570         iLog->Log(buf);
       
   571         if ( aTraceFlag ) 
       
   572             {
       
   573             TraceL( buf );
       
   574             }
       
   575         sourceFieldId = aLandmark.NextPositionFieldId(sourceFieldId);
       
   576         
       
   577         CleanupStack::PopAndDestroy( buffer );
       
   578         }
       
   579     }
       
   580     
       
   581     
       
   582 // ---------------------------------------------------------
       
   583 // CPosTp154::TraceL
       
   584 //
       
   585 // (other items were commented in a header).
       
   586 // ---------------------------------------------------------
       
   587 //
       
   588 void CPosTp154::TraceL(const TDesC& msg)
       
   589     {
       
   590     _LIT8( KEnd, "\r\n" );
       
   591 
       
   592     RFile file;
       
   593     TInt err = file.Open(iFileSession, KFileTrace, EFileWrite);
       
   594     if (err == KErrNotFound)
       
   595         {
       
   596         file.Create(iFileSession, KFileTrace, EFileWrite);
       
   597         }
       
   598 
       
   599     HBufC8* line8 = CnvUtfConverter::ConvertFromUnicodeToUtf8L( msg );
       
   600     
       
   601     TInt pos( 0 );
       
   602     file.Seek( ESeekEnd, pos );
       
   603     file.Write( *line8 );
       
   604     file.Write( KEnd );
       
   605     file.Close();
       
   606 
       
   607     delete line8;
       
   608     }
       
   609 
       
   610 //  End of File