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